sonata-project / SonataMediaBundle

Symfony SonataMediaBundle
https://docs.sonata-project.org/projects/SonataMediaBundle
MIT License
450 stars 496 forks source link

Usage without sonata admin ? #991

Closed Padam87 closed 8 years ago

Padam87 commented 8 years ago

php app\console cache:warmup

Fatal error: Class 'Sonata\AdminBundle\Controller\CRUDController' not found in .....\vendor\sonata-project\media-bundle\Controller\GalleryAdminController.php on line 19

To fix it I have to add the admin bundle to the dependencies, which is far from ideal. Any suggestions?

greg0ire commented 8 years ago

Wow. Does anyone know why the admin bundle isn't required ? It is referenced in GalleryAdminController, apparently. Using this controller is supposed to be optional, maybe ?

core23 commented 8 years ago

It is an optional dependency and should work without the SonataAdminBundle, see: https://github.com/sonata-project/SonataMediaBundle/blob/master/DependencyInjection/SonataMediaExtension.php#L86

This xml files are referencing the Controller.

greg0ire commented 8 years ago

Indeed, I just saw that in the doc.

greg0ire commented 8 years ago

@Padam87 , can you use app/console -vvv cache:warmup and give us a full stack trace ?

Padam87 commented 8 years ago

It is only an issue when warming the cache after a clear. Unfortunately the -vvv option wasn't really helpful.

Fatal error: Class 'Sonata\AdminBundle\Controller\CRUDController' not found in .....\vendor\sonata-project\media-bundle\Controller\GalleryAdminController.php on line 19

[Symfony\Component\Debug\Exception\ClassNotFoundException]
Attempted to load class "CRUDController" from namespace "Sonata\AdminBundle\Controller".
Did you forget a "use" statement for another namespace?

Exception trace: () at ....\vendor\sonata-project\media-bundle\Controller\GalleryAdminController.php:19

Padam87 commented 8 years ago

Maybe I'm wrong, but this seems like a class loader problem?

greg0ire commented 8 years ago

Well if you don't have the admin bundle, it will not load, so yeah…

greg0ire commented 8 years ago

How does warmup find this class ? Is there any route pointing to it? Or does it just look into every Controller directory ?

greg0ire commented 8 years ago

@Padam87 : have you had a look at the routes (debug:router ? )

Padam87 commented 8 years ago

Yep, routing is not the problem. It is caused by the DiExtra bundle.

https://github.com/schmittjoh/JMSDiExtraBundle/blob/master/HttpKernel/ControllerInjectorsWarmer.php#L46

Can be fixed by adding the file to the blacklist.

jms_di_extra:
    cache_warmer:
        controller_file_blacklist:
            - %kernel.root_dir%/../vendor/sonata-project/media-bundle/Controller/GalleryAdminController.php
greg0ire commented 8 years ago

Would you do us a big favor and document that ?

Padam87 commented 8 years ago

Yep, I will add it to the troubleshooting section.