Closed 71kris closed 8 months ago
Can anyone please help?
I found a way to resolve it. See my reply on stackoverflow
If this is not the way to do it, do let me know and provide a better solution.
Some support of this bundle would be welcome - hello owners of this bundle. As it stands it does give an impression that this bundle is dead. That nobody cares. Is it the case?
I found a way to resolve it. See my reply on stackoverflow
If this is not the way to do it, do let me know and provide a better solution.
It's the way symfony works. See also https://symfony.com/doc/current/service_container/service_decoration.html
Some support of this bundle would be welcome - hello owners of this bundle. As it stands it does give an impression that this bundle is dead. That nobody cares. Is it the case?
That's open source principle ; people helps when they have time because it's free. If you expect a better support/maintenance, you should sponsor the repository you're using ;)
Hello Vincent Thank you for your reply. I could sponsor this bundle they way I see it ok with me. If you create a youtube channel for example, I'm more than happy to watch it and to allow you to monetize that way.
I understand where you stand, that you work for free, people expect things and you get nothing out of it. But that is your business model. That is a fact. If it doesn't work it's not this product's end users fault, is it.
You've got a successful product but your business model probably needs a rethink. You're clever bunch of people, you know better than I probably.
I'm in the same boat to some extent but that's another story... I wish you all the best, don't get annoyed when people ask for help, please.
I could sponsor this bundle they way I see it ok with me. If you create a youtube channel for example, I'm more than happy to watch it and to allow you to monetize that way.
I think you underestimate the time it would take VS the amount of money I would gain with this. You also underestimate how many hours it already takes me to just maintain these bundles.
I understand where you stand, that you work for free, people expect things and you get nothing out of it. But that is your business model. That is a fact. If it doesn't work it's not this product's end users fault, is it.
You've got a successful product but your business model probably needs a rethink. You're clever bunch of people, you know better than I probably.
It's not my business model. It's how open source works and the fact you misunderstand it. Repositories are available for free, and therefor are maintained by nobody and everybody at the same time. If you want something in this repository, do it or pay someone to do it.
It's the product's end user fault when he think someone else should give a service for free. When someone else helps you, be happy. If nobody does, it happen.
Of course Vincent. I miss understand it. You're right, you're always right.
Environment
Symfony 6.4, PHP 8.3.2 Apache Win Server 2.4.58
Sonata packages
show
``` $ composer show --latest 'sonata-project/*' # Put the result here. ``` Direct dependencies required in composer.json: sonata-project/admin-bundle 4.29.2 4.29.3 The missing Symfony Admin Generator sonata-project/doctrine-extensions 2.3.0 2.3.0 Doctrine2 behavioral extensions sonata-project/doctrine-orm-admin-bundle 4.15.0 4.15.0 Integrate Doctrine ORM into the SonataAdminBundle sonata-project/form-extensions 2.3.0 2.3.0 Symfony form extensions sonata-project/twig-extensions 2.4.0 2.4.0 Sonata twig extensions sonata-project/user-bundle 5.10.0 5.10.0 Symfony SonataUserBundle Transitive dependencies not required in composer.json: sonata-project/block-bundle 5.1.0 5.1.0 Symfony SonataBlockBundle sonata-project/exporter 3.3.0 3.3.0 Lightweight Exporter library
Symfony packages
show
``` $ composer show --latest 'symfony/*' # Put the result here. ``` Direct dependencies required in composer.json: symfony/asset v6.4.0 v7.0.3 Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files symfony/asset-mapper v6.4.2 v7.0.3 Maps directories of assets & makes them available in a public directory with versioned filenames. symfony/browser-kit v6.4.0 v7.0.3 Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically symfony/console v6.4.2 v7.0.3 Eases the creation of beautiful and testable command line interfaces symfony/css-selector v6.4.0 v7.0.3 Converts CSS selectors to XPath expressions symfony/debug-bundle v6.4.0 v7.0.3 Provides a tight integration of the Symfony VarDumper component and the ServerLogCommand from MonologBridge into the Symfony full-stack framework symfony/doctrine-messenger v6.4.2 v7.0.3 Symfony Doctrine Messenger Bridge symfony/dotenv v6.4.2 v7.0.3 Registers environment variables from a .env file symfony/expression-language v6.4.2 v7.0.3 Provides an engine that can compile and evaluate expressions symfony/flex v2.4.3 v2.4.4 Composer plugin for Symfony symfony/form v6.4.1 v7.0.3 Allows to easily create, process and reuse HTML forms symfony/framework-bundle v6.4.2 v7.0.3 Provides a tight integration between Symfony components and the Symfony full-stack framework symfony/http-client v6.4.2 v7.0.3 Provides powerful methods to fetch HTTP resources synchronously or asynchronously symfony/intl v6.4.2 v7.0.3 Provides access to the localization data of the ICU library symfony/mailer v6.4.2 v7.0.3 Helps sending emails symfony/maker-bundle v1.52.0 v1.54.0 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code. symfony/mime v6.4.0 v7.0.3 Allows manipulating MIME messages symfony/monolog-bundle v3.10.0 v3.10.0 Symfony MonologBundle symfony/notifier v6.4.0 v7.0.3 Sends notifications via one or more channels (email, SMS, ...) symfony/phpunit-bridge v7.0.2 v7.0.3 Provides utilities for PHPUnit, especially user deprecation notices management symfony/process v6.4.2 v7.0.3 Executes commands in sub-processes symfony/property-access v6.4.0 v7.0.3 Provides functions to read and write from/to an object or array using a simple string notation symfony/property-info v6.4.0 v7.0.3 Extracts information about PHP class' properties using metadata of popular sources symfony/runtime v6.4.0 v7.0.3 Enables decoupling PHP applications from global state symfony/security-bundle v6.4.2 v7.0.3 Provides a tight integration of the Security component into the Symfony full-stack framework symfony/serializer v6.4.2 v7.0.3 Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON. symfony/stimulus-bundle v2.13.3 v2.14.2 Integration with your Symfony app & Stimulus! symfony/stopwatch v6.4.0 v7.0.3 Provides a way to profile code symfony/string v6.4.2 v7.0.3 Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way symfony/translation v6.4.2 v7.0.3 Provides tools to internationalize your application symfony/twig-bundle v6.4.0 v7.0.3 Provides a tight integration of Twig into the Symfony full-stack framework symfony/ux-turbo v2.13.2 v2.14.2 Hotwire Turbo integration for Symfony symfony/validator v6.4.2 v7.0.3 Provides tools to validate values symfony/web-link v6.4.0 v7.0.3 Manages links between resources symfony/web-profiler-bundle v6.4.2 v7.0.3 Provides a development tool that gives detailed information about the execution of any request symfony/yaml v6.4.0 v7.0.3 Loads and dumps YAML files Transitive dependencies not required in composer.json: symfony/cache v6.4.2 v7.0.3 Provides extended PSR-6, PSR-16 (and tags) implementations symfony/cache-contracts v3.4.0 v3.4.0 Generic abstractions related to caching symfony/clock v6.4.2 v7.0.3 Decouples applications from the system clock symfony/config v6.4.0 v7.0.3 Helps you find, load, combine, autofill and validate configuration values of any kind symfony/dependency-injection v6.4.2 v7.0.3 Allows you to standardize and centralize the way objects are constructed in your application symfony/deprecation-contracts v3.4.0 v3.4.0 A generic function and convention to trigger deprecation notices symfony/doctrine-bridge v6.4.2 v7.0.3 Provides integration for Doctrine with various Symfony components symfony/dom-crawler v6.4.0 v7.0.3 Eases DOM navigation for HTML and XML documents symfony/error-handler v6.4.0 v7.0.3 Provides tools to manage errors and ease debugging PHP code symfony/event-dispatcher v6.4.2 v7.0.3 Provides tools that allow your application components to communicate with each other by dispatching events and listening to them symfony/event-dispatcher-contracts v3.4.0 v3.4.0 Generic abstractions related to dispatching event symfony/filesystem v6.4.0 v7.0.3 Provides basic utilities for the filesystem symfony/finder v6.4.0 v7.0.0 Finds files and directories via an intuitive fluent interface symfony/http-client-contracts v3.4.0 v3.4.0 Generic abstractions related to HTTP clients symfony/http-foundation v6.4.2 v7.0.3 Defines an object-oriented layer for the HTTP specification symfony/http-kernel v6.4.2 v7.0.3 Provides a structured process for converting a Request into a Response symfony/messenger v6.4.0 v7.0.3 Helps applications send and receive messages to/from other applications or via message queues symfony/monolog-bridge v6.4.0 v7.0.3 Provides integration for Monolog with various Symfony components symfony/options-resolver v6.4.0 v7.0.0 Provides an improved replacement for the array_replace PHP function symfony/password-hasher v6.4.0 v7.0.3 Provides password hashing utilities symfony/polyfill-intl-grapheme v1.28.0 v1.29.0 Symfony polyfill for intl's grapheme_* functions symfony/polyfill-intl-icu v1.28.0 v1.29.0 Symfony polyfill for intl's ICU-related data and classes symfony/polyfill-intl-idn v1.28.0 v1.29.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions symfony/polyfill-intl-normalizer v1.28.0 v1.29.0 Symfony polyfill for intl's Normalizer class and related functions symfony/polyfill-mbstring v1.28.0 v1.29.0 Symfony polyfill for the Mbstring extension symfony/polyfill-php83 v1.28.0 v1.29.0 Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions symfony/routing v6.4.2 v7.0.3 Maps an HTTP request to a set of configuration variables symfony/security-acl v3.3.3 v3.3.3 Symfony Security Component - ACL (Access Control List) symfony/security-core v6.4.0 v7.0.3 Symfony Security Component - Core Library symfony/security-csrf v6.4.0 v7.0.3 Symfony Security Component - CSRF Library symfony/security-http v6.4.0 v7.0.3 Symfony Security Component - HTTP Integration symfony/service-contracts v3.4.1 v3.4.1 Generic abstractions related to writing services symfony/translation-contracts v3.4.1 v3.4.1 Generic abstractions related to translation symfony/twig-bridge v6.4.2 v7.0.3 Provides integration for Twig with various Symfony components symfony/var-dumper v6.4.2 v7.0.3 Provides mechanisms for walking through any arbitrary PHP variable symfony/var-exporter v6.4.2 v7.0.3 Allows exporting any serializable PHP data structure to plain PHP code
PHP version
$ php -v PHP 8.3.2 (cli) (built: Jan 16 2024 20:47:57) (ZTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.3.2, Copyright (c) Zend Technologies
Subject
Hello guys, I'm having hard time migrating sonata admin + sonata user to the latest symfony 6.4 + sonata admin + user admin. I've got old project that needs upgrading. I'm stuck on extending UserAdmin class with my own UserAdmin class extending Sonata\UserBundle\Admin\Model\UserAdmin as BaseAdmin.
It seems to me that despite the fact that I have got my constructor in my custom UserAdmin class sonata/symfony is still crashing pointing to a BaseAdmin constructor that has got only 1 parameter. My custom class has got 3 parameters as defined below in my service.
I've been trying to google it, I checked docs, I tried to fix it myself but I cannot find what I'm missing. Would you kindly point me in the right direction, please. I'm really stuck.
I tried to add additional arguments in services file but that clashes with requirements for __construct(). Here's related UserAdmin code:
use Sonata\UserBundle\Admin\Model\UserAdmin as BaseAdmin;
use Doctrine\ORM\EntityManager;
use Sonata\UserBundle\Model\UserManagerInterface;
//...
`class UserAdmin extends BaseAdmin { protected $tokenStorage; protected $container; public EntityManager $doctrine;
}` Here's my service:
app.admin.user:
class: App\Admin\UserAdmin
arguments: ["@sonata.user.manager.user", "@security.token_storage", "@doctrine.orm.entity_manager"]
tags:
- { name: sonata.admin, model_class: App\Entity\User, manager_type: orm, group: sonata_user, label: User, pager_type: "simple" }
public: true
I've also tried to add to my service instead of passing arguments (as above) and having no constructor at all in my custom UserAdmin calss but doing this and trying to use calls methods (below):
calls:
- [ setSecurityToken, ["@security.token_storage"] ]
- [ setEntityManager, ["@doctrine.orm.entity_manager"] ]
- [ setContainer, ["@service_container"] ]
that is also not working as expected because when I try to access security tokenStorage in:
`protected function configureQuery(ProxyQueryInterface $query): ProxyQueryInterface { $rootAlias = current($query->getRootAliases()); dump($this->tokenStorage);exit; // <-- null $user = $this->tokenStorage->getToken()->getUser();
security token storage is null, meaning I cannot get the query right.
Here's my sonata.user.yaml config:
`sonata_user: security_acl: false manager_type: orm # can be orm or mongodb
impersonating_route: sonata_user_impersonating
Minimal repository with the bug
Steps to reproduce
Expected results
Load UserAdmin with my own constructor with additional parameters.
Actual results
1ArgumentCountError HTTP 500 Internal Server Error Too few arguments to function App\Admin\UserAdmin::__construct(), 1 passed in C:_projects_git-repos\pg\var\cache\dev\ContainerQpxfz3Z\getSonata_User_Admin_UserService.php on line 44 and exactly 3 expected1
Stack trace: `ArgumentCountError: Too few arguments to function App\Admin\UserAdmin::__construct(), 1 passed in C:_projects_git-repos\pg\var\cache\dev\ContainerQpxfz3Z\getSonata_User_Admin_UserService.php on line 44 and exactly 3 expected
at C:_projects_git-repos\pg\src\Admin\UserAdmin.php:74 at App\Admin\UserAdmin->construct() (C:_projects_git-repos\pg\var\cache\dev\ContainerQpxfz3Z\getSonata_User_Admin_UserService.php:44) at ContainerQpxfz3Z\getSonata_User_Admin_UserService::ContainerQpxfz3Z{closure}() (C:_projects_git-repos\pg\vendor\symfony\dependency-injection\Container.php:409) at Symfony\Component\DependencyInjection\Container->getService() (C:_projects_git-repos\pg\vendor\symfony\dependency-injection\Argument\ServiceLocator.php:40) at Symfony\Component\DependencyInjection\Argument\ServiceLocator->get() (C:_projects_git-repos\pg\vendor\sonata-project\admin-bundle\src\Admin\Pool.php:291) at Sonata\AdminBundle\Admin\Pool->getInstance() (C:_projects_git-repos\pg\vendor\sonata-project\admin-bundle\src\Route\AdminPoolLoader.php:51) at Sonata\AdminBundle\Route\AdminPoolLoader->load() (C:_projects_git-repos\pg\vendor\symfony\config\Loader\FileLoader.php:146) at Symfony\Component\Config\Loader\FileLoader->doImport() (C:_projects_git-repos\pg\vendor\symfony\config\Loader\FileLoader.php:98) at Symfony\Component\Config\Loader\FileLoader->import() (C:_projects_git-repos\pg\vendor\symfony\routing\Loader\YamlFileLoader.php:212) at Symfony\Component\Routing\Loader\YamlFileLoader->parseImport() (C:_projects_git-repos\pg\vendor\symfony\routing\Loader\YamlFileLoader.php:99) at Symfony\Component\Routing\Loader\YamlFileLoader->load() (C:_projects_git-repos\pg\vendor\symfony\config\Loader\FileLoader.php:167) at Symfony\Component\Config\Loader\FileLoader->doImport() (C:_projects_git-repos\pg\vendor\symfony\config\Loader\FileLoader.php:87) at Symfony\Component\Config\Loader\FileLoader->import() (C:_projects_git-repos\pg\vendor\symfony\routing\Loader\Configurator\RoutingConfigurator.php:45) at Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator->import() (C:_projects_git-repos\pg\vendor\symfony\framework-bundle\Kernel\MicroKernelTrait.php:79) at App\Kernel->configureRoutes() (C:_projects_git-repos\pg\vendor\symfony\framework-bundle\Kernel\MicroKernelTrait.php:213) at App\Kernel->loadRoutes() (C:_projects_git-repos\pg\vendor\symfony\routing\Loader\ObjectLoader.php:55) at Symfony\Component\Routing\Loader\ObjectLoader->load() (C:_projects_git-repos\pg\vendor\symfony\config\Loader\DelegatingLoader.php:37) at Symfony\Component\Config\Loader\DelegatingLoader->load() (C:_projects_git-repos\pg\vendor\symfony\framework-bundle\Routing\DelegatingLoader.php:67) at Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader->load() (C:_projects_git-repos\pg\vendor\symfony\framework-bundle\Routing\Router.php:65) at Symfony\Bundle\FrameworkBundle\Routing\Router->getRouteCollection() (C:_projects_git-repos\pg\vendor\symfony\routing\Router.php:327) at Symfony\Component\Routing\Router->getGeneratorDumperInstance() (C:_projects_git-repos\pg\vendor\symfony\routing\Router.php:301) at Symfony\Component\Routing\Router->Symfony\Component\Routing{closure}() (C:_projects_git-repos\pg\vendor\symfony\config\ResourceCheckerConfigCacheFactory.php:36) at Symfony\Component\Config\ResourceCheckerConfigCacheFactory->cache() (C:_projects_git-repos\pg\vendor\symfony\routing\Router.php:299) at Symfony\Component\Routing\Router->getGenerator() (C:_projects_git-repos\pg\vendor\symfony\routing\Router.php:221) at Symfony\Component\Routing\Router->generate() (C:_projects_git-repos\pg\vendor\symfony\web-profiler-bundle\EventListener\WebDebugToolbarListener.php:85) at Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener->onKernelResponse() (C:_projects_git-repos\pg\vendor\symfony\event-dispatcher\Debug\WrappedListener.php:116) at Symfony\Component\EventDispatcher\Debug\WrappedListener->invoke() (C:_projects_git-repos\pg\vendor\symfony\event-dispatcher\EventDispatcher.php:220) at Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (C:_projects_git-repos\pg\vendor\symfony\event-dispatcher\EventDispatcher.php:56) at Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (C:_projects_git-repos\pg\vendor\symfony\event-dispatcher\Debug\TraceableEventDispatcher.php:139) at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch() (C:_projects_git-repos\pg\vendor\symfony\http-kernel\HttpKernel.php:214) at Symfony\Component\HttpKernel\HttpKernel->filterResponse() (C:_projects_git-repos\pg\vendor\symfony\http-kernel\HttpKernel.php:202) at Symfony\Component\HttpKernel\HttpKernel->handleRaw() (C:_projects_git-repos\pg\vendor\symfony\http-kernel\HttpKernel.php:76) at Symfony\Component\HttpKernel\HttpKernel->handle() (C:_projects_git-repos\pg\vendor\symfony\http-kernel\EventListener\ErrorListener.php:117) at Symfony\Component\HttpKernel\EventListener\ErrorListener->onKernelException() (C:_projects_git-repos\pg\vendor\symfony\event-dispatcher\Debug\WrappedListener.php:116) at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke() (C:_projects_git-repos\pg\vendor\symfony\event-dispatcher\EventDispatcher.php:220) at Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (C:_projects_git-repos\pg\vendor\symfony\event-dispatcher\EventDispatcher.php:56) at Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (C:_projects_git-repos\pg\vendor\symfony\event-dispatcher\Debug\TraceableEventDispatcher.php:139) at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch() (C:_projects_git-repos\pg\vendor\symfony\http-kernel\HttpKernel.php:239) at Symfony\Component\HttpKernel\HttpKernel->handleThrowable() (C:_projects_git-repos\pg\vendor\symfony\http-kernel\HttpKernel.php:132) at Symfony\Component\HttpKernel\HttpKernel->terminateWithException() (C:_projects_git-repos\pg\vendor\symfony\http-kernel\EventListener\DebugHandlersListener.php:82) at Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::Symfony\Component\HttpKernel\EventListener{closure}() (C:_projects_git-repos\pg\vendor\symfony\error-handler\ErrorHandler.php:531) at Symfony\Component\ErrorHandler\ErrorHandler->handleException() `
Please help if you can. I've no idea how to resolve this. Thank you in advance.