APY / APYDataGridBundle

Symfony Datagrid Bundle
MIT License
492 stars 344 forks source link

Symfony 5 Support #1060

Closed kaamaa closed 2 years ago

kaamaa commented 3 years ago

Hi,

is there any Version of APY/APYDataGridBundle than can be used with Symfony 5 (e.g. 5.2)?

The current version runs into problems e.g. Twig Problems: "attempted to load class "twig_function_method" from the global namespace. did you forget a "use" statement?" while twig_function_method is depreciated

I've also spotted an issue with the service xml file on the tag.

Cheers Martin

kaamaa commented 3 years ago

I finally got the APYDataGridBundle running with Symfony 5.2.3

Julio Montoya did 99% of the work, by preparing the Datagridbundle for Twig > 3.0

Please use jmontoyaa / APYDataGridBundle : master

In addition three steps are required:

Please add the following Statement to service.xml

</service>
   <service id="%grid.class%" alias="grid" public="true">
</service>

Using the console you can check if the the grid service is available:

php bin/console cache:clear
php bin/console debug:autowiring --all

As Templating is not available any more, you need to replace in Grid.PHP / getGridResponse

Old: return $this->container->get('templating')->renderResponse($view, $parameters, $response);
New: return new Response($this->container->get('twig')->render($view, $parameters, $response));

Finally you need to exchange in Configuration.php / getConfigTreeBuilder

Old: ->scalarNode('theme')->defaultValue('APYDataGridBundle::blocks.html.twig')->end() 
New: ->scalarNode('theme')->defaultValue('@APYDataGrid/blocks.html.twig')->end()

Then run

php bin/console cache:clear 

again and start you application.

My Controller function looks like this

public function GridAction(RequestStack $requestStack, grid $grid)
 {
    $request = $requestStack->getCurrentRequest();

As I'm not familiär with GitHub past "Composer require" statements, I can't upload my version.

Cheers Martin

kaamaa commented 3 years ago

The new version can be found here, it includes also changes vor PHP Version 7.4

https://github.com/kaamaa/APYDataGridBundle

kirya-dev commented 3 years ago

Hello. Its very helpfull sugges.

Me also need goto newest symfony version.

@kaamaa you are need todo same replacing on twig in GridManager. Also needed to remove symfony/templating depency from composer.json.

After it please add version tag.

npotier commented 3 years ago

Hello,

I've been working on this branch https://github.com/APY/APYDataGridBundle/tree/feature/sf5-compat to have a working Bundle with latest version on Symfony 5.

All tests are green and I've created a real life example that also allows to test the bundle locally : https://github.com/npotier/apydatagrid-demo

I've created a PR here : https://github.com/APY/APYDataGridBundle/pull/1063

Feel free to tell me what you think about it.

npotier commented 2 years ago

Hello.

Symfony 5 support has been released on the repository, on the tag 4.0

it is now available on packagist.

Feel free to test this new version on your projects and to create issues if needed

FredDut commented 2 years ago

Hello. Is there a way to use twig3 with the 4.0? Currently: "apy/datagrid-bundle 4.0 requires twig/twig ^2.10".