Giter VIP home page Giter VIP logo

sonataautoconfigurebundle's Introduction

SonataAutoConfigureBundle

Tries to auto configure your admin classes and extensions, so you don't have to.

PHP Version Latest Stable Version Latest Unstable Version

Build Status Coverage Status

Documentation

Installation

1. Add dependency with Composer

composer require kunicmarko/sonata-auto-configure-bundle

2. Enable the bundle for all Symfony environments:

// bundles.php
return [
    //...
    KunicMarko\SonataAutoConfigureBundle\SonataAutoConfigureBundle::class => ['all' => true],
];

Configuration

sonata_auto_configure:
    admin:
        suffix: Admin
        manager_type: orm
        label_catalogue: ~
        label_translator_strategy: ~
        translation_domain: ~
        group: ~
        pager_type: ~
    entity:
        namespaces:
            - { namespace: App\Entity, manager_type: orm }
    controller:
        suffix: Controller
        namespaces:
            - App\Controller\Admin

How does it work

This bundle tries to guess some stuff about your admin class. You only have to create your admin classes and be sure that the admin directory is included in auto discovery and that autoconfigure is enabled.

This bundle will tag your admin classes with sonata.admin, then we find all admin classes and if autoconfigure is enabled we take the class name. If you defined a suffix in the config (by default it is Admin) we remove it to get the name of the entity, so if you had CategoryAdmin we get Category.

After that we check if the AdminOption annotation is present, annotations have a higher priority than our guesses. If no annotation is defined or some of the values that are mandatory are not present we still try to guess.

First, we set the label and based on previous example it will be Category.

Then, we set the admin code which will be the service id, in our case it is the class name.

After, we try to find the Category entity in the list of namespaces you defined (by default it is just App\Entity). If the entity is not found an exception is thrown and you will probably need to use an annotation to define the entity. You can set the manager_type attribute per namespace.

By default we will take manager_type from annotations, if they are not present we will take it from the namespace definition. If you define the entity in your annotation but not the manager_type then we will take the manager type from the bundle configuration that will be available as a sonata_auto_configure.admin.manager_type parameter.

Then we try to guess a controller, same as for the entity we try to guess it in the list of namespaces but we add a suffix (as in most situations people name it CategoryController) that you can disable in configuration. If there is no controller we leave it as null and sonata will add its default controller.

And that is it. We have all the info we need for defining an admin class, if you used some of the other tag options when defining your admin class you will have to use Annotation or register admin on your own with autoconfigure: false that would look like:

App\Admin\CategoryAdmin:
    arguments: [~, App\Entity\Category, ~]
    autoconfigure: false
    tags:
        - { name: sonata.admin, manager_type: orm, label: Category }
    public: true

Since your admin class is autowired you can still use setter injection but you have to add a @required annotation:

/**
 * @required
 */
public function setSomeService(SomeService $someService)
{
    $this->someService = $someService;
}

Annotation

AdminOptions

<?php

namespace App\Admin;

use KunicMarko\SonataAutoConfigureBundle\Annotation as Sonata;
use App\Controller\Admin\CategoryController;
use App\Entity\Category;
use Sonata\AdminBundle\Admin\AbstractAdmin;

/**
 * @Sonata\AdminOptions(
 *     label="Category",
 *     managerType="orm",
 *     group="Category",
 *     showInDashboard=true,
 *     showMosaicButton=true,
 *     keepOpen=true,
 *     onTop=true,
 *     icon="<i class='fa fa-user'></i>",
 *     labelTranslatorStrategy="sonata.admin.label.strategy.native",
 *     labelCatalogue="App",
 *     translationDomain="messages",
 *     pagerType="simple",
 *     controller=CategoryController::class,
 *     entity=Category::class,
 *     adminCode="admin_code",
 *     autowireEntity=true,
 *     templates={
 *         "list": "admin/category/list.html.twig"
 *     },
 *     children={"app.admin.product"}
 * )
 */
final class CategoryAdmin extends AbstractAdmin
{
}

AdminExtensionOptions

<?php

namespace App\Admin;

use KunicMarko\SonataAutoConfigureBundle\Annotation as Sonata;
use Sonata\AdminBundle\Admin\AbstractAdminExtension;

/**
 * @Sonata\AdminExtensionOptions(
 *     global=true
 * )
 */
final class GlobalExtension extends AbstractAdminExtension
{
}
<?php

namespace App\Admin;

use KunicMarko\SonataAutoConfigureBundle\Annotation as Sonata;
use Sonata\AdminBundle\Admin\AbstractAdminExtension;
use App\Admin\ActivityAdmin;

/**
 * @Sonata\AdminExtensionOptions(
 *     target={"app.admin.project", ActivityAdmin::class}
 * )
 */
final class SortableExtension extends AbstractAdminExtension
{
}

sonataautoconfigurebundle's People

Contributors

greg0ire avatar gremo avatar kunicmarko20 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sonataautoconfigurebundle's Issues

serviceId is not defined

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
{
//...

Ignore some admin via configuration

Feature Request

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.

Add the ability to configure admin extensions

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.

Block management feature?

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.

When I try to alias my admin, I get an error

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.

sonata_auto_configure.admin.suffix ingored?

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.

Default value for mosaic button

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.

Autowire doesn't work (when admin is injected in another service)

Environment

Sonata packages

$ 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

Symfony packages

$ 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 version

$ 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

Subject

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.

Steps to reproduce

  • Create MyAdmin admin
  • Create MyListener, and try to inject MyAdmin into the constructor

Expected results

MyAdmin admin is injected into MyListener.

Actual results

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.

Field names for children

Environment

Sonata packages

$ 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

Symfony packages

$ 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 version

$ 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

Subject

Problem: "Calling 'addChild' without second argument is deprecated since 3.35 and will not be allowed in 4.0".

Steps to reproduce

Have filled "children" option in annotations.

Expected results

No mentioned deprecation. :)

Actual results

Deprecation, mentioned in subject.

Ability to configure the translation domain

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.

Autoconfiguration of Extensions

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 ?

Add the ability to configure admin templates

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
{
}

Setting defaults using the configuration

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

Admin without an Entity

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

Default value for adminCode

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.