Rectangle 27 0

php Sonata Admin Bundle custom query for list to use existing Repository?


Unfortunately you can't. It is because the sonata admin has to build (or in your case) finishes the query (because of filtering, limiting, paging and so on..)

Note
Rectangle 27 0

php Sonata Admin Bundle custom query for list to use existing Repository?


/**
     * {@inheritDoc}
     */
    public function createQuery($context = 'list')
    {
        $repository = $this->modelManager->getEntityManager($this->getClass())->getRepository($this->getClass());
        $query = new ProxyQuery($repository->createMyCustomQueryBuilder());

        foreach ($this->extensions as $extension) {
            $extension->configureQuery($this, $query, $context);
        }

        return $query;
    }

Of course you can, as far as you return a Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery instance :

Note