kunicmarko20 / sonataautoconfigurebundle Goto Github PK
View Code? Open in Web Editor NEWSymfony Bundle that auto configures Sonata Admin.
License: MIT License
Symfony Bundle that auto configures Sonata Admin.
License: MIT License
I am looking at this and I think this is wrong, the point of the bundle is to autoconfigure stuff not to require someone to add annotation, I am thinking of adding logic of guessing the target admin, if not found we set global true and if there is an annotation, we ignore our guessing logic. wdyt @gremo ?
Right now, when using this bundle, you can auto-configure admins and extensions.
What about blocks? Adding blocks is tedious: you need a service (at least, you need to specify the name
argument), you need a tag (although you can use _instance_of
), and, finally, add the block service id under blocks
in sonata_block
configuration.
Offer the ability to configure the translation domain for each admin, or set in using the configuration (for every auto-configured admin).
This way, one can configure the label catalogue and translation domain: generally, the are both the same domain.
Hi, as I see currently default value for adminCode
option constains path of admin, for example: App\Admin\UserAdmin
, but according to the docs, it should be something like admin.user
.
Maybe I can't understand how Symfony 4 services works, but I want to create an alias (my admin id/code is still app.admin.experience
):
# config/sonata_admin.yaml
# ...
services:
# service aliases
App\Admin\ExperienceAdmin: '@app.admin.experience'
You have requested a non-existent service "app.admin.experience".
But, of course exists, and it's auto-configured using this bundle.
I'm using default config that looks exactly like in README. In my setup I'm using doctrine's inheritance, so my base entity is Product which is abstract and it's descendants like ProductBook, ProductClub etc... So I have an
<?php
namespace App\Admin;
use App\Entity\Product\Product;
use Sonata\AdminBundle\Admin\AbstractAdmin;
class ProductAdminBase extends AbstractAdmin
{
...
and correspondigly
<?php
namespace App\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
class ProductBookAdmin extends ProductAdminBase
{
...
I'm getting following error:
$ bin/console cache:clear
In AutoConfigureAdminClassesCompilerPass.php line 130:
Entity "ProductAdminBase" not found, looked in "App\Entity" namespaces.
I thought sonata_auto_configure.admin.suffix
is exactly to filter this case that's why I renamed my AbstractProductAdmin to ProductAdminBase but as you see without luck.
Hi, I think that default value for mosaic button should be taken from sonata_admin.show_mosaic_button
option. Currently it is set to true and I have to change it in each admin class.
Admin extension can be easly configured:
App\Admin\Extension\:
resource: '../../src/Admin/Extension'
tags: [{ name: 'sonata.admin.extension' }]
... but, if you need a global extension, you need to waste another two lines of code:
App\Admin\Extension\GlobalExtension:
tags: [{ name: 'sonata.admin.extension', global: true }]
It would be nice a new annotation to configure admin extensions.
I have an DigestAdmin/DigestController defined which has no corresponding entity. The error I get is following:
!!
!! In AutoConfigureAdminClassesCompilerPass.php line 130:
!!
!! Entity "Digest" not found, looked in "App\Entity" namespaces.
!!
!!
!!
Tried to override the DigestAdmin service with no luck
$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle 3.44.0 3.45.1 The missing Symfony Admin Generator
sonata-project/block-bundle 3.13.0 3.14.0 Symfony SonataBlockBundle
sonata-project/cache 1.1.1 2.0.1 Cache library
sonata-project/cache-bundle 2.4.2 3.0.1 This bundle provides caching services
sonata-project/classification-bundle 3.7.1 3.8.0 Symfony SonataClassificationBundle
sonata-project/core-bundle 3.11.2 3.15.1 Symfony SonataCoreBundle
sonata-project/datagrid-bundle 2.4.0 2.4.0 Symfony SonataDatagridBundle
sonata-project/doctrine-extensions 1.1.5 1.1.5 Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.8.0 3.8.1 Symfony Sonata / Integrate Doctrine ORM into the SonataAdmin...
sonata-project/easy-extends-bundle 2.5.0 2.5.0 Symfony SonataEasyExtendsBundle
sonata-project/exporter 1.11.0 1.11.0 Lightweight Exporter library
sonata-project/formatter-bundle 4.1.2 4.1.2 Symfony SonataFormatterBundle
sonata-project/media-bundle 3.17.1 3.18.1 Symfony SonataMediaBundle
sonata-project/notification-bundle 3.5.1 3.5.1 Symfony SonataNotificationBundle
sonata-project/page-bundle 3.9.1 3.10.0 This bundle provides a Site and Page management through cont...
sonata-project/seo-bundle 2.6.2 2.7.0 Symfony SonataSeoBundle
sonata-project/user-bundle 4.2.3 4.2.3 Symfony SonataUserBundle
$ composer show --latest 'symfony/*'
symfony/apache-pack v1.0.1 v1.0.1 A pack for Apache support in Symfony
symfony/asset v4.2.2 v4.2.2 Symfony Asset Component
symfony/cache v4.2.2 v4.2.2 Symfony Cache component with PSR-6, PSR-16, and tags
symfony/config v4.2.2 v4.2.2 Symfony Config Component
symfony/console v4.2.2 v4.2.2 Symfony Console Component
symfony/contracts v1.0.2 v1.0.2 A set of abstractions extracted out of the Symfony components
symfony/css-selector v4.2.2 v4.2.2 Symfony CssSelector Component
symfony/debug v4.2.2 v4.2.2 Symfony Debug Component
symfony/debug-bundle v4.2.2 v4.2.2 Symfony DebugBundle
symfony/debug-pack v1.0.7 v1.0.7 A debug pack for Symfony projects
symfony/dependency-injection v4.2.2 v4.2.2 Symfony DependencyInjection Component
symfony/doctrine-bridge v4.2.2 v4.2.2 Symfony Doctrine Bridge
symfony/dotenv v4.2.2 v4.2.2 Registers environment variables from a .env file
symfony/event-dispatcher v4.2.2 v4.2.2 Symfony EventDispatcher Component
symfony/expression-language v4.2.2 v4.2.2 Symfony ExpressionLanguage Component
symfony/filesystem v4.2.2 v4.2.2 Symfony Filesystem Component
symfony/finder v4.2.2 v4.2.2 Symfony Finder Component
symfony/flex v1.1.8 v1.1.8 Composer plugin for Symfony
symfony/form v4.2.2 v4.2.2 Symfony Form Component
symfony/framework-bundle v4.2.2 v4.2.2 Symfony FrameworkBundle
symfony/http-foundation v4.2.2 v4.2.2 Symfony HttpFoundation Component
symfony/http-kernel v4.2.2 v4.2.2 Symfony HttpKernel Component
symfony/inflector v4.2.2 v4.2.2 Symfony Inflector Component
symfony/intl v4.2.2 v4.2.2 A PHP replacement layer for the C intl extension that includes additi...
symfony/maker-bundle v1.11.3 v1.11.3 Symfony Maker helps you create empty commands, controllers, form clas...
symfony/monolog-bridge v4.2.2 v4.2.2 Symfony Monolog Bridge
symfony/monolog-bundle v3.3.1 v3.3.1 Symfony MonologBundle
symfony/options-resolver v4.2.2 v4.2.2 Symfony OptionsResolver Component
symfony/orm-pack v1.0.6 v1.0.6 A pack for the Doctrine ORM
symfony/polyfill-intl-icu v1.10.0 v1.10.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring v1.10.0 v1.10.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72 v1.10.0 v1.10.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP vers...
symfony/process v4.2.2 v4.2.2 Symfony Process Component
symfony/profiler-pack v1.0.4 v1.0.4 A pack for the Symfony web profiler
symfony/property-access v4.2.2 v4.2.2 Symfony PropertyAccess Component
symfony/property-info v4.2.2 v4.2.2 Symfony Property Info Component
symfony/routing v4.2.2 v4.2.2 Symfony Routing Component
symfony/security-acl v3.0.1 v3.0.1 Symfony Security Component - ACL (Access Control List)
symfony/security-bundle v4.2.2 v4.2.2 Symfony SecurityBundle
symfony/security-core v4.2.2 v4.2.2 Symfony Security Component - Core Library
symfony/security-csrf v4.2.2 v4.2.2 Symfony Security Component - CSRF Library
symfony/security-guard v4.2.2 v4.2.2 Symfony Security Component - Guard
symfony/security-http v4.2.2 v4.2.2 Symfony Security Component - HTTP Integration
symfony/serializer v4.2.2 v4.2.2 Symfony Serializer Component
symfony/serializer-pack v1.0.2 v1.0.2 A pack for the Symfony serializer
symfony/stopwatch v4.2.2 v4.2.2 Symfony Stopwatch Component
symfony/swiftmailer-bundle v3.2.5 v3.2.5 Symfony SwiftmailerBundle
symfony/templating v4.2.2 v4.2.2 Symfony Templating Component
symfony/translation v4.2.2 v4.2.2 Symfony Translation Component
symfony/twig-bridge v4.2.2 v4.2.2 Symfony Twig Bridge
symfony/twig-bundle v4.2.2 v4.2.2 Symfony TwigBundle
symfony/validator v4.2.2 v4.2.2 Symfony Validator Component
symfony/var-dumper v4.2.2 v4.2.2 Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter v4.2.2 v4.2.2 A blend of var_export() + serialize() to turn any serializable data s...
symfony/web-link v4.2.2 v4.2.2 Symfony WebLink Component
symfony/web-profiler-bundle v4.2.2 v4.2.2 Symfony WebProfilerBundle
symfony/web-server-bundle v4.2.2 v4.2.2 Symfony WebServerBundle
symfony/webpack-encore-bundle v1.1.0 v1.1.0 Integration with your Symfony app & Webpack Encore!
symfony/workflow v4.2.2 v4.2.2 Symfony Workflow Component
symfony/yaml v4.2.2 v4.2.2 Symfony Yaml Component
$ php -v
PHP 7.1.25 (cli) (built: Dec 5 2018 06:50:31) ( NTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.25, Copyright (c) 1999-2018, by Zend Technologies
Autowiring doesn't work: when you try to inject MyAdmin
in another service, using the type hint.
IMHO this can be easily fixed Use the original service id instead of the admin code in AutoConfigureAdminClassesCompilerPass
. I'll make a PR.
MyAdmin
adminMyListener
, and try to inject MyAdmin
into the constructorMyAdmin
admin is injected into MyListener
.
Cannot autowire service "App\EventListener\MyListener": argument "$myAdmin" of method "__construct()" references class "App\Admin\MyAdmin" but no such service exists. You should maybe alias this class to the existing "app.admin.my_admin" service.
Right now, since getTemplates
and getTemplate($name)
in AbstractAdmin
re both deprecated, the only way to configure template is using the service definition. Using the annotation, this is a no-sense (just defining a service to change a template).
Templates support can be added this way:
/**
* @Sonata\AdminOptions(
* templates={
* "notify": "admin/category/notify.html.twig"
* }
* )
*/
class CategoryAdmin extends AbstractAdmin
{
}
$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle 3.51.0 3.51.0 The missing Symfony Admin Generator
sonata-project/block-bundle 3.15.0 3.15.0 Symfony SonataBlockBundle
sonata-project/cache 1.1.1 2.0.1 Cache library
sonata-project/cache-bundle 2.4.2 3.1.0 This bundle provides caching services
sonata-project/core-bundle 3.17.0 3.17.0 Symfony SonataCoreBundle
sonata-project/datagrid-bundle 2.5.0 3.0.0 Symfony SonataDatagridBundle
sonata-project/doctrine-extensions 1.3.0 1.3.0 Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.10.0 3.10.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/intl-bundle 2.6.0 2.6.0 Symfony SonataIntlBundle
sonata-project/media-bundle 3.20.1 3.20.1 Symfony SonataMediaBundle
sonata-project/notification-bundle 3.6.2 3.6.2 Symfony SonataNotificationBundle
sonata-project/page-bundle 3.11.1 3.11.1 This bundle provides a Site and Page management through container and block services
sonata-project/seo-bundle 2.7.0 2.7.0 Symfony SonataSeoBundle
sonata-project/translation-bundle 2.4.2 2.4.2 SonataTranslationBundle
$ composer show --latest 'symfony/*'
symfony/asset v4.3.2 v4.3.2 Symfony Asset Component
symfony/browser-kit v4.3.2 v4.3.2 Symfony BrowserKit Component
symfony/cache v4.3.2 v4.3.2 Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts v1.1.5 v1.1.5 Generic abstractions related to caching
symfony/config v4.3.2 v4.3.2 Symfony Config Component
symfony/console v4.3.2 v4.3.2 Symfony Console Component
symfony/css-selector v4.3.2 v4.3.2 Symfony CssSelector Component
symfony/debug v4.3.2 v4.3.2 Symfony Debug Component
symfony/dependency-injection v4.3.2 v4.3.2 Symfony DependencyInjection Component
symfony/doctrine-bridge v4.3.2 v4.3.2 Symfony Doctrine Bridge
symfony/dom-crawler v4.3.2 v4.3.2 Symfony DomCrawler Component
symfony/dotenv v4.3.2 v4.3.2 Registers environment variables from a .env file
symfony/event-dispatcher v4.3.2 v4.3.2 Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v1.1.5 v1.1.5 Generic abstractions related to dispatching event
symfony/expression-language v4.3.2 v4.3.2 Symfony ExpressionLanguage Component
symfony/filesystem v4.3.2 v4.3.2 Symfony Filesystem Component
symfony/finder v4.3.2 v4.3.2 Symfony Finder Component
symfony/flex v1.4.5 v1.4.5 Composer plugin for Symfony
symfony/form v4.3.2 v4.3.2 Symfony Form Component
symfony/framework-bundle v4.3.2 v4.3.2 Symfony FrameworkBundle
symfony/http-foundation v4.3.2 v4.3.2 Symfony HttpFoundation Component
symfony/http-kernel v4.3.2 v4.3.2 Symfony HttpKernel Component
symfony/inflector v4.3.2 v4.3.2 Symfony Inflector Component
symfony/intl v4.3.2 v4.3.2 A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/messenger v4.3.2 v4.3.2 Symfony Messenger Component
symfony/mime v4.3.2 v4.3.2 A library to manipulate MIME messages
symfony/monolog-bridge v4.3.2 v4.3.2 Symfony Monolog Bridge
symfony/monolog-bundle v3.4.0 v3.4.0 Symfony MonologBundle
symfony/options-resolver v4.3.2 v4.3.2 Symfony OptionsResolver Component
symfony/phpunit-bridge v4.3.2 v4.3.2 Symfony PHPUnit Bridge
symfony/polyfill-intl-icu v1.11.0 v1.11.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn v1.11.0 v1.11.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-mbstring v1.11.0 v1.11.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72 v1.11.0 v1.11.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73 v1.11.0 v1.11.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/process v4.3.2 v4.3.2 Symfony Process Component
symfony/profiler-pack v1.0.4 v1.0.4 A pack for the Symfony web profiler
symfony/property-access v4.3.2 v4.3.2 Symfony PropertyAccess Component
symfony/property-info v4.3.2 v4.3.2 Symfony Property Info Component
symfony/routing v4.3.2 v4.3.2 Symfony Routing Component
symfony/security-acl v3.0.2 v3.0.2 Symfony Security Component - ACL (Access Control List)
symfony/security-bundle v4.3.2 v4.3.2 Symfony SecurityBundle
symfony/security-core v4.3.2 v4.3.2 Symfony Security Component - Core Library
symfony/security-csrf v4.3.2 v4.3.2 Symfony Security Component - CSRF Library
symfony/security-guard v4.3.2 v4.3.2 Symfony Security Component - Guard
symfony/security-http v4.3.2 v4.3.2 Symfony Security Component - HTTP Integration
symfony/serializer v4.3.2 v4.3.2 Symfony Serializer Component
symfony/serializer-pack v1.0.2 v1.0.2 A pack for the Symfony serializer
symfony/service-contracts v1.1.5 v1.1.5 Generic abstractions related to writing services
symfony/stopwatch v4.3.2 v4.3.2 Symfony Stopwatch Component
symfony/swiftmailer-bundle v3.2.8 v3.2.8 Symfony SwiftmailerBundle
symfony/templating v4.3.2 v4.3.2 Symfony Templating Component
symfony/translation v4.3.2 v4.3.2 Symfony Translation Component
symfony/translation-contracts v1.1.5 v1.1.5 Generic abstractions related to translation
symfony/twig-bridge v4.3.2 v4.3.2 Symfony Twig Bridge
symfony/twig-bundle v4.3.2 v4.3.2 Symfony TwigBundle
symfony/validator v4.3.2 v4.3.2 Symfony Validator Component
symfony/var-dumper v4.3.2 v4.3.2 Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter v4.3.2 v4.3.2 A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-link v4.3.2 v4.3.2 Symfony WebLink Component
symfony/web-profiler-bundle v4.3.2 v4.3.2 Symfony WebProfilerBundle
symfony/webpack-encore-bundle v1.6.2 v1.6.2 Integration with your Symfony app & Webpack Encore!
symfony/workflow v4.3.2 v4.3.2 Symfony Workflow Component
symfony/yaml v4.3.2 v4.3.2 Symfony Yaml Component
$ php -v
PHP 7.3.7 (cli) (built: Jul 5 2019 12:44:05) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.7, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.7, Copyright (c) 1999-2018, by Zend Technologies
Problem: "Calling 'addChild' without second argument is deprecated since 3.35 and will not be allowed in 4.0".
Have filled "children" option in annotations.
No mentioned deprecation. :)
Deprecation, mentioned in subject.
Can't see any effect of it.
In AnnotationException.php line 69:
[Creation Error] The annotation @AdminOptions declared on class App\Admin\DigestAdmin does not have a property named "serviceId". Available properties:
label, managerType, group, showInDashboard, keepOpen, onTop, icon, labelTranslatorStrategy, labelCatalogue, pagerType, adminCode, entity, controller
<?php
namespace App\Admin;
use KunicMarko\SonataAutoConfigureBundle\Annotation\AdminOptions;
use App\Controller\Admin\DigestController;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Route\RouteCollection;
/**
* @AdminOptions(
* label="Digest",
* managerType="orm",
* group="specials",
* showInDashboard=true,
* keepOpen=true,
* onTop=true,
* icon="<i class='fa fa-user'></i>",
* labelTranslatorStrategy="sonata.admin.label.strategy.native",
* labelCatalogue="App",
* pagerType="simple",
* controller=DigestController::class,
* entity=null,
* adminCode="admin_code",
* )
*/
class DigestAdmin extends AbstractAdmin
{
//...
I have some admin that are coming from other bundle that are not base on SoanaAutoConfigureBundle but have a autoconfigure=true.
Since the compiler pass is overriding the configuration of all "sonata.admin" service that are autoconfigure the bundle configuration is overiden.
We should have a way to whitelist/blacklist the list of admin base on class name, directory and/or bundle name.
How about setting defaults using the configuration? Sometimes I need annotations just to change the labelTranslatorStrategy
or the labelCatalogue
.
sonata_auto_configure:
defaults:
label_catalogue: admin
label_translator_strategy: sonata.admin.label.strategy.underscore
show_mosaic_button: false
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.