sonata-project / SonataMediaBundle

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

API controllers can't be loaded by FOSRest because the services are marked private #1652

Closed jeroendk closed 4 years ago

jeroendk commented 4 years ago

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.56.1 3.56.1 The missing Symfony Admin Generator
sonata-project/block-bundle              3.18.2 4.0.0  Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  2.0.1  Cache library
sonata-project/core-bundle               3.17.2 3.17.2 Symfony SonataCoreBundle (abandoned)
sonata-project/datagrid-bundle           2.5.0  3.0.1  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.4.0  1.4.0  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.12.0 3.12.0 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle       2.5.0  2.5.0  Symfony SonataEasyExtendsBundle
sonata-project/exporter                  2.0.1  2.0.1  Lightweight Exporter library
sonata-project/media-bundle              3.21.0 3.21.0 Symfony SonataMediaBundle
sonata-project/user-bundle               4.5.1  4.5.1  Symfony SonataUserBundle

friendsofsymfony/rest-bundle     2.6.0  2.6.0

Symfony packages

$ composer show --latest 'symfony/*'
symfony/asset                      v4.4.1  v4.4.1  Symfony Asset Component
symfony/browser-kit                v4.4.1  v4.4.1  Symfony BrowserKit Component
symfony/cache                      v4.4.1  v4.4.1  Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts            v2.0.1  v2.0.1  Generic abstractions related to caching
symfony/config                     v4.4.1  v4.4.1  Symfony Config Component
symfony/console                    v4.4.1  v4.4.1  Symfony Console Component
symfony/css-selector               v4.4.1  v4.4.1  Symfony CssSelector Component
symfony/debug                      v4.4.1  v4.4.1  Symfony Debug Component
symfony/debug-bundle               v4.4.1  v4.4.1  Symfony DebugBundle
symfony/debug-pack                 v1.0.7  v1.0.7  A debug pack for Symfony projects
symfony/dependency-injection       v4.4.1  v4.4.1  Symfony DependencyInjection Component
symfony/doctrine-bridge            v4.4.1  v4.4.1  Symfony Doctrine Bridge
symfony/dom-crawler                v4.4.1  v4.4.1  Symfony DomCrawler Component
symfony/dotenv                     v4.4.1  v4.4.1  Registers environment variables from a .env file
symfony/error-handler              v4.4.1  v4.4.1  Symfony ErrorHandler Component
symfony/event-dispatcher           v4.4.1  v4.4.1  Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v1.1.7  v2.0.1  Generic abstractions related to dispatching event
symfony/expression-language        v4.4.1  v4.4.1  Symfony ExpressionLanguage Component
symfony/filesystem                 v4.4.1  v4.4.1  Symfony Filesystem Component
symfony/finder                     v4.4.1  v4.4.1  Symfony Finder Component
symfony/flex                       v1.5.3  v1.5.3  Composer plugin for Symfony
symfony/form                       v4.4.1  v4.4.1  Symfony Form Component
symfony/framework-bundle           v4.4.1  v4.4.1  Symfony FrameworkBundle
symfony/http-client                v4.4.1  v4.4.1  Symfony HttpClient component
symfony/http-client-contracts      v2.0.1  v2.0.1  Generic abstractions related to HTTP clients
symfony/http-foundation            v4.4.1  v4.4.1  Symfony HttpFoundation Component
symfony/http-kernel                v4.4.1  v4.4.1  Symfony HttpKernel Component
symfony/inflector                  v4.4.1  v4.4.1  Symfony Inflector Component
symfony/intl                       v4.4.1  v4.4.1  A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/mailer                     v4.4.1  v4.4.1  Symfony Mailer Component
symfony/maker-bundle               v1.14.3 v1.14.3 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing bo...
symfony/mime                       v4.4.1  v4.4.1  A library to manipulate MIME messages
symfony/monolog-bridge             v4.4.1  v4.4.1  Symfony Monolog Bridge
symfony/monolog-bundle             v3.5.0  v3.5.0  Symfony MonologBundle
symfony/options-resolver           v4.4.1  v4.4.1  Symfony OptionsResolver Component
symfony/orm-pack                   v1.0.7  v1.0.7  A pack for the Doctrine ORM
symfony/phpunit-bridge             v4.4.1  v5.0.1  Symfony PHPUnit Bridge
symfony/polyfill-intl-icu          v1.13.1 v1.13.1 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn          v1.13.1 v1.13.1 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-mbstring          v1.13.1 v1.13.1 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72             v1.13.1 v1.13.1 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73             v1.13.1 v1.13.1 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/process                    v4.4.1  v4.4.1  Symfony Process Component
symfony/profiler-pack              v1.0.4  v1.0.4  A pack for the Symfony web profiler
symfony/property-access            v4.4.1  v4.4.1  Symfony PropertyAccess Component
symfony/property-info              v4.4.1  v4.4.1  Symfony Property Info Component
symfony/routing                    v4.4.1  v4.4.1  Symfony Routing Component
symfony/security-acl               v3.0.4  v3.0.4  Symfony Security Component - ACL (Access Control List)
symfony/security-bundle            v4.4.1  v4.4.1  Symfony SecurityBundle
symfony/security-core              v4.4.1  v4.4.1  Symfony Security Component - Core Library
symfony/security-csrf              v4.4.1  v4.4.1  Symfony Security Component - CSRF Library
symfony/security-guard             v4.4.1  v4.4.1  Symfony Security Component - Guard
symfony/security-http              v4.4.1  v4.4.1  Symfony Security Component - HTTP Integration
symfony/sendgrid-mailer            v4.4.1  v4.4.1  Symfony Sendgrid Mailer Bridge
symfony/serializer                 v4.4.1  v4.4.1  Symfony Serializer Component
symfony/serializer-pack            v1.0.2  v1.0.2  A pack for the Symfony serializer
symfony/service-contracts          v2.0.1  v2.0.1  Generic abstractions related to writing services
symfony/stopwatch                  v4.4.1  v4.4.1  Symfony Stopwatch Component
symfony/swiftmailer-bundle         v3.4.0  v3.4.0  Symfony SwiftmailerBundle
symfony/templating                 v4.4.1  v4.4.1  Symfony Templating Component
symfony/test-pack                  v1.0.6  v1.0.6  A pack for functional and end-to-end testing within a Symfony app
symfony/translation                v4.4.1  v4.4.1  Symfony Translation Component
symfony/translation-contracts      v2.0.1  v2.0.1  Generic abstractions related to translation
symfony/twig-bridge                v4.4.1  v4.4.1  Symfony Twig Bridge
symfony/twig-bundle                v4.4.1  v4.4.1  Symfony TwigBundle
symfony/validator                  v4.4.1  v4.4.1  Symfony Validator Component
symfony/var-dumper                 v4.4.1  v4.4.1  Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter               v4.4.1  v4.4.1  A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-link                   v4.4.1  v4.4.1  Symfony WebLink Component
symfony/web-profiler-bundle        v4.4.1  v4.4.1  Symfony WebProfilerBundle
symfony/web-server-bundle          v4.4.1  v4.4.1  Symfony WebServerBundle
symfony/webpack-encore-bundle      v1.7.2  v1.7.2  Integration with your Symfony app & Webpack Encore!
symfony/yaml                       v4.4.1  v4.4.1  Symfony Yaml Component

PHP version

$ php -v
PHP 7.3.4

Subject

When I follow the documentation to configure the API part of the Sonata Media bundle, the FOSRest route loader throws an error. This is because the following controller services are private by default:

The route loader tries to find the services in the container and fails.

Steps to reproduce

Configure the Sonata Media API routes as described here: https://sonata-project.org/bundles/media/3-x/doc/reference/api.html.

Expected results

No error on cache clear.

Actual results

In FileLoader.php line 180:

  Class could not be determined for Controller identified by "sonata.media.controller.api.gallery" in /var/www/html/symfony/vendor/sonata-project/media-bundle/src/Resources/co  
  nfig/routing/api.xml (which is being imported from "/var/www/html/symfony/config/routes/sonata_media.yaml"). Make sure there is a loader supporting the "rest" type.           

In RestRouteLoader.php line 153:

  Class could not be determined for Controller identified by "sonata.media.controller.api.gallery".  

Should these services be made public? If so I am happy to provide a pull request.

core23 commented 4 years ago

Can you provide a PR with a fix @jeroendk ?

stale[bot] commented 4 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.