Q
Q
Qixing2015-02-09 07:22:02
symfony
Qixing, 2015-02-09 07:22:02

How to use your repositories in BuildForm?

Good afternoon. How to use your repositories in this case:
Repository:

<?php
namespace ParserBundle\Repository;
use Doctrine\ORM\EntityRepository;


class CrbrItemMakerRepository extends EntityRepository
{

    public function findAllQuery()
    {
        return $this
            ->createQueryBuilder('m')
            ->orderBy('m.name', 'ASC')
            ->getQuery()
            ->useResultCache(true, 60*60*24, 'category_cache');

    }

}

use ParserBundle\Repository\CrbrItemMakerRepository;
......
 $builder
            ->add(
                'maker',
                'entity',
                array(
                    'class' => 'ParserBundle:CrbrItemMaker',
                    'property' => 'name',
                    'required' => false,
                    'data' => $maker,
                    'empty_value' => '-- Все --',
                    'query_builder' => function(CrbrItemMakerRepository $er ) use ( $options ) {
                                return $er->findAllQuery();
                        }
                )
            )

Catchable Fatal Error
: Argument 1 passed to CrbrBundle\Form\Filter\CrbrItemFilter::CrbrBundle\Form\Filter\{closure}() must be an instance of ParserBundle\Repository\CrbrItemMakerRepository, instance of Doctrine\ORM\EntityRepository given

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
romashka_sky, 2015-02-09
@romashka_sky

For the ParserBundle:CrbrItemMaker entity, you need to specify the repository : doctrine-orm.readthedocs.org/en/latest/reference/w...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question