webinarium / DataTablesBundle

Symfony bundle for DataTables plugin.
MIT License
16 stars 9 forks source link

Symfony 4 services need to be public #7

Closed inrumi closed 6 years ago

inrumi commented 6 years ago

I'm getting this deprecation warning:

User Deprecated: The "datatables" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.

Even when I mark the service as public

AppBundle\DataTables\: resource: '../../src/AppBundle/DataTables' autowire: true public: true tags: [ datatable ]

webinarium commented 6 years ago

What Symfony version do you use? I can't reproduce the issue using 3.4.4.

I have attached my demo app that I used to reproduce the issue. Could you please try it and let me know whether it works for you? It's ready to go, just run composer install right after unpack. If it works for you, then maybe you will notice what I'm doing differently and advise me. Or feel free to provide me with some demo where the issue is present.

Thank you!

issue7.tar.gz

inrumi commented 6 years ago

I'm using 3.4.4 aswell, I downloaded the file and tested, these are the steps to reproduce it:

  1. composer install
  2. click to order column "login"
  3. in debug toolbar check the last ajax request profile
  4. in the profile go to logs and there is the deprecation notice
webinarium commented 6 years ago

I have released new version 2.3.1 which addresses this issue. Please upgrade and then change your controller as in the updated wiki (see "Symfony 3.4 and above" example there).

Particularly, you don't need to retrieve this service from the container, so the service should remain private. Instead of getting the service manually, just inject it:

public function usersAction(Request $request, DataTablesInterface $datatables): JsonResponse

Please let me know whether this helps.

inrumi commented 6 years ago

the warning is gone after updating and injecting the service.

Thank you a lot!