grid-bundle icon indicating copy to clipboard operation
grid-bundle copied to clipboard

Not working with symfony 3

Open asjustas opened this issue 9 years ago • 4 comments

In symfony 3 you cant get request from DI container (https://github.com/symfony/symfony/blob/master/UPGRADE-3.0.md). So if you want to make your library to work with symfony 3 you must provide request when creating grid. I wanted to make pull request but don`t get time.

public function indexAction(Request $request)
    {
        /** @var \Doctrine\ORM\EntityRepository $repository */
        $repository = $this->getDoctrine()->getRepository('PedroTeixeiraTestBundle:TestEntity');
        $queryBuilder = $repository->createQueryBuilder('r');

        /** @var \PedroTeixeira\Bundle\TestBundle\Grid\TestGrid $grid */
        $grid = $this->get('pedroteixeira.grid')->createGrid(TestGrid::class, $request);
        $grid->setQueryBuilder($queryBuilder);

        if ($grid->isResponseAnswer()) {
            return $grid->render();
        }

        return array(
            'grid'   => $grid->render()
        );
    }

asjustas avatar Feb 23 '16 08:02 asjustas

Moreover, it is necessary to change the namespace in the class FullTransformer.

Original: Symfony\Component\Locale\Stub\DateFormat\FullTransformer New: use Symfony\Component\Intl\DateFormatter\DateFormat\FullTransformer

It is possible to solve as own filters and renderers. I am new in symfony, so I dont know ideal reason how to keep compatibility.

Sorry for my english.

pesektomas avatar Mar 03 '16 15:03 pesektomas

I forked this repository and update code for symfony3 compatibility. Please, check my commits in repo and give me feedback. I dont know if i should do pull request before someone checks it.

Thenks

pesektomas avatar Mar 08 '16 14:03 pesektomas

Hi @pesovo, yes, please send the pull request so we can code review it.

Thanks for the support!

pedro-teixeira avatar Mar 08 '16 16:03 pedro-teixeira

OK, I sended it, but i apologize in advance if there is something incomprehensible

pesektomas avatar Mar 09 '16 07:03 pesektomas