sonata-project / SonataMediaBundle

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

Impossible to invoke a method ("id") on a null variable - Custom User #1709

Closed Onita77 closed 4 years ago

Onita77 commented 4 years ago

Environment

Sonata packages

Symfony 4.4.5 - Custom User Entity

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.58.0 3.61.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.18.4 3.18.4 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  2.0.1  Cache library
sonata-project/classification-bundle     3.10.1 3.10.1 Symfony SonataClassificationBundle
sonata-project/core-bundle               3.17.2 3.17.2 Symfony SonataCoreBundle (abandoned)
sonata-project/datagrid-bundle           2.5.0  2.5.0  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.5.1  1.5.1  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.14.0 3.14.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                  1.11.1 1.11.1 Lightweight Exporter library
sonata-project/formatter-bundle          4.1.3  4.1.3  Symfony SonataFormatterBundle
sonata-project/intl-bundle               2.7.0  2.7.0  Symfony SonataIntlBundle
sonata-project/media-bundle              3.23.1 3.23.1 Symfony SonataMediaBundle
sonata-project/news-bundle               3.11.0 3.11.0 Symfony SonataNewsBundle

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

PHP version

$ php -v
PHP 7.1.33 (cli) (built: Nov 28 2019 14:00:51) ( NTS )

Subject

I have installed News Bundle. I have configured it following the steps indicated in the Official documentation.


sonata_news:
    title:        Sonata Project
    link:         https://sonata-project.org
    description:  Cool bundles on top of Symfony2
    salt:         'secureToken'
    permalink_generator: sonata.news.permalink.date # sonata.news.permalink.collection
    permalink:
        date:     '%%1$04d/%%2$02d/%%3$02d/%%4$s' # => 2012/02/01/slug
    db_driver:    'doctrine_orm' # doctrine_orm or doctrine_mongodb it is mandatory to choose one here
    class:
        post:       App\Application\Sonata\NewsBundle\Entity\Post
        comment:    App\Application\Sonata\NewsBundle\Entity\Comment
        media:      App\Application\Sonata\MediaBundle\Entity\Media
        tag:        App\Application\Sonata\ClassificationBundle\Entity\Tag
        collection: App\Application\Sonata\ClassificationBundle\Entity\Collection
        user:       App\Entity\BaseUser

    admin:
        post:
            class:       Sonata\NewsBundle\Admin\PostAdmin
            controller:  SonataAdminBundle:CRUD
            translation: SonataNewsBundle
        comment:
            class:       Sonata\NewsBundle\Admin\CommentAdmin
            controller:  SonataNewsBundle:CommentAdmin
            translation: SonataNewsBundle

    comment:
        notification:
            emails:   [email@example.org, email2@example.org]
            from:     no-reply@sonata-project.org
            template: '@SonataNews/Mail/comment_notification.txt.twig'

I would like to associate the author field of the NewsBundle entity Post with the User entity that I created, but that does not work I have the impression that it does not make the association.

Steps to reproduce

Expected results

Should see the Product add/update form but it does not work.

Actual results

Impossible to invoke a method ("id") on a null variable. {% if sonata_admin.field_description.associationadmin.id(sonata_admin.value) %}

github-actions[bot] commented 4 years ago

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