Sonataadminbundle: Unable to find one of the following templates: "@SonataCore/FlashMessage/render.html.twig", "@SonataTwig/FlashMessage/render.html.twig" in @!SonataAdmin/standard_layout.html.twig at line 331.

Created on 29 Jun 2020  路  20Comments  路  Source: sonata-project/SonataAdminBundle

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.71.0 3.71.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.20.0 3.20.0 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  2.0.1  Cache library
sonata-project/doctrine-extensions       1.6.0  1.6.0  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.19.0 3.19.0 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  2.2.0  2.2.0  Lightweight Exporter library
sonata-project/form-extensions           1.5.0  1.5.0  Symfony form extensions
sonata-project/twig-extensions           1.3.0  1.3.0  Sonata twig extensions

Symfony packages

$ composer show --latest 'symfony/*'
symfony/asset                      v4.4.10 v4.4.10 Symfony Asset Component
symfony/browser-kit                v4.4.10 v4.4.10 Symfony BrowserKit Component
symfony/cache                      v4.4.10 v4.4.10 Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts            v2.1.2  v2.1.2  Generic abstractions related to caching
symfony/config                     v4.4.10 v4.4.10 Symfony Config Component
symfony/console                    v4.4.10 v4.4.10 Symfony Console Component
symfony/css-selector               v4.4.10 v4.4.10 Symfony CssSelector Component
symfony/debug                      v4.4.10 v4.4.10 Symfony Debug Component
symfony/debug-bundle               v4.4.10 v4.4.10 Symfony DebugBundle
symfony/debug-pack                 v1.0.8  v1.0.8  A debug pack for Symfony projects
symfony/dependency-injection       v4.4.10 v4.4.10 Symfony DependencyInjection Component
symfony/doctrine-bridge            v4.4.10 v4.4.10 Symfony Doctrine Bridge
symfony/dom-crawler                v4.4.10 v4.4.10 Symfony DomCrawler Component
symfony/dotenv                     v4.4.10 v4.4.10 Registers environment variables from a .env file
symfony/error-handler              v4.4.10 v4.4.10 Symfony ErrorHandler Component
symfony/event-dispatcher           v4.4.10 v4.4.10 Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v1.1.7  v2.1.2  Generic abstractions related to dispatching event
symfony/expression-language        v4.4.10 v4.4.10 Symfony ExpressionLanguage Component
symfony/filesystem                 v4.4.10 v4.4.10 Symfony Filesystem Component
symfony/finder                     v4.4.10 v4.4.10 Symfony Finder Component
symfony/flex                       v1.8.4  v1.8.4  Composer plugin for Symfony
symfony/form                       v4.4.10 v4.4.10 Symfony Form Component
symfony/framework-bundle           v4.4.10 v4.4.10 Symfony FrameworkBundle
symfony/http-client                v4.4.10 v4.4.10 Symfony HttpClient component
symfony/http-client-contracts      v2.1.2  v2.1.2  Generic abstractions related to HTTP clients
symfony/http-foundation            v4.4.10 v4.4.10 Symfony HttpFoundation Component
symfony/http-kernel                v4.4.10 v4.4.10 Symfony HttpKernel Component
symfony/inflector                  v4.4.10 v4.4.10 Symfony Inflector Component
symfony/intl                       v4.4.10 v4.4.10 A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/maker-bundle               v1.19.0 v1.19.0 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.10 v4.4.10 A library to manipulate MIME messages
symfony/monolog-bridge             v4.4.10 v4.4.10 Symfony Monolog Bridge
symfony/monolog-bundle             v3.5.0  v3.5.0  Symfony MonologBundle
symfony/options-resolver           v4.4.10 v4.4.10 Symfony OptionsResolver Component
symfony/orm-pack                   v1.0.8  v1.0.8  A pack for the Doctrine ORM
symfony/phpunit-bridge             v5.1.2  v5.1.2  Symfony PHPUnit Bridge
symfony/polyfill-intl-grapheme     v1.17.1 v1.17.1 Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-icu          v1.17.1 v1.17.1 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn          v1.17.1 v1.17.1 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer   v1.17.1 v1.17.1 Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring          v1.17.1 v1.17.1 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72             v1.17.0 v1.17.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73             v1.17.1 v1.17.1 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80             v1.17.1 v1.17.1 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-uuid              v1.17.1 v1.17.1 Symfony polyfill for uuid functions
symfony/process                    v4.4.10 v4.4.10 Symfony Process Component
symfony/profiler-pack              v1.0.4  v1.0.4  A pack for the Symfony web profiler
symfony/property-access            v4.4.10 v4.4.10 Symfony PropertyAccess Component
symfony/property-info              v4.4.10 v4.4.10 Symfony Property Info Component
symfony/routing                    v4.4.10 v4.4.10 Symfony Routing Component
symfony/security-acl               v3.0.4  v3.0.4  Symfony Security Component - ACL (Access Control List)
symfony/security-bundle            v4.4.10 v4.4.10 Symfony SecurityBundle
symfony/security-core              v4.4.10 v4.4.10 Symfony Security Component - Core Library
symfony/security-csrf              v4.4.10 v4.4.10 Symfony Security Component - CSRF Library
symfony/security-guard             v4.4.10 v4.4.10 Symfony Security Component - Guard
symfony/security-http              v4.4.10 v4.4.10 Symfony Security Component - HTTP Integration
symfony/serializer                 v4.4.10 v4.4.10 Symfony Serializer Component
symfony/serializer-pack            v1.0.3  v1.0.3  A pack for the Symfony serializer
symfony/service-contracts          v2.1.2  v2.1.2  Generic abstractions related to writing services
symfony/stopwatch                  v4.4.10 v4.4.10 Symfony Stopwatch Component
symfony/string                     v5.1.2  v5.1.2  Symfony String component
symfony/templating                 v4.4.10 v4.4.10 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.10 v4.4.10 Symfony Translation Component
symfony/translation-contracts      v2.1.2  v2.1.2  Generic abstractions related to translation
symfony/twig-bridge                v4.4.10 v4.4.10 Symfony Twig Bridge
symfony/twig-bundle                v4.4.10 v4.4.10 Symfony TwigBundle
symfony/twig-pack                  v1.0.0  v1.0.0  A Twig pack for Symfony projects
symfony/validator                  v4.4.10 v4.4.10 Symfony Validator Component
symfony/var-dumper                 v4.4.10 v4.4.10 Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter               v4.4.10 v4.4.10 A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-link                   v4.4.10 v4.4.10 Symfony WebLink Component
symfony/web-profiler-bundle        v4.4.10 v4.4.10 Symfony WebProfilerBundle
symfony/webpack-encore-bundle      v1.7.3  v1.7.3  Integration with your Symfony app & Webpack Encore!
symfony/yaml                       v4.4.10 v4.4.10 Symfony Yaml Component

PHP version

$ php -v
PHP 7.2.31-1+ubuntu20.04.1+deb.sury.org+1 (cli) (built: May 14 2020 08:28:17) ( NTS )

Subject

Steps to reproduce

composer up

Expected results

working webstie

Actual results

Unable to find one of the following templates: "@SonataCore/FlashMessage/render.html.twig", "@SonataTwig/FlashMessage/render.html.twig" in @!SonataAdmin/standard_layout.html.twig at line 331.

bug unconfirmed

Most helpful comment

@axzx missing SonataDoctrineBundle registration
@minolone You register deprecated SonataTwigBundle.

Can you add this:

    Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle::class => ['all' => true],
    Sonata\Form\Bridge\Symfony\SonataFormBundle::class => ['all' => true],
    Sonata\Twig\Bridge\Symfony\SonataTwigBundle::class => ['all' => true],

I'm using it in sandbox and it works.

All 20 comments

@axzx

SonataCoreBundle it is optional now. Read this

You should register SonataTwigBundle by add this line to your bundles.php:

Sonata\Twig\Bridge\Symfony\SonataTwigBundle::class => ['all' => true],

or you can add (not recommended) to composer to keep this bundle in your project:

"sonata-project/core-bundle": "^3.20",

@axzx

SonataCoreBundle it is optional now. Read this

You should register SonataTwigBundle by add this line to your bundles.php:

Sonata\Twig\Bridge\Symfony\SonataTwigBundle::class => ['all' => true],

or you can add (not recommended) to composer to keep this bundle in your project:

"sonata-project/core-bundle": "^3.20",

okej, but I have an another bug:
There are no registered paths for namespace "SonataCore".
but I don't know from what is.

what about code in standard_layout.html.twig

<script src="{{ asset(
                    'bundles/sonatacore/vendor/moment/locale/' ~
                    localeForMoment ~
                    '.js'
                ) }}"></script>


md5-6929ac8a5b052bd7308462e87f98a39a





md5-7d4c3dab8be53447c9840b941e3c276c



'bundles/sonatacore/vendor/bootstrap/dist/css/bootstrap.min.css',
'bundles/sonatacore/vendor/components-font-awesome/css/font-awesome.min.css',
'bundles/sonatacore/vendor/ionicons/css/ionicons.min.css',

etc

okej, but I have an another bug:
There are no registered paths for namespace "SonataCore".
but I don't know from what is.

It mean you using @SonataCore/.. without registred bundle. In updated temples you can find something like this:

{% block notice %}
    {% include ['@SonataCore/FlashMessage/render.html.twig', '@SonataTwig/FlashMessage/render.html.twig'] %}
{% endblock notice %}

It mean use first existing template. This ignore registred paths exception too.

what about code in standard_layout.html.twig

<script src="{{ asset(
                    'bundles/sonatacore/vendor/moment/locale/' ~
                    localeForMoment ~
                    '.js'
                ) }}"></script>
<script src="{{ asset('bundles/sonatacore/vendor/select2/select2_locale_' ~ localeForSelect2 ~ '.js') }}"></script>
'bundles/sonatacore/vendor/bootstrap/dist/css/bootstrap.min.css',
'bundles/sonatacore/vendor/components-font-awesome/css/font-awesome.min.css',
'bundles/sonatacore/vendor/ionicons/css/ionicons.min.css',

etc

All sonatacore files are using in AdminBundle and PageBundle. This files was move to SonataAdminBundle, (SonataPageBundle require SonataAdminBundle) and will be install by EventListener on assets:install to sonatacore directory.

okej, but I have an another bug:
There are no registered paths for namespace "SonataCore".
but I don't know from what is.

It mean you using @SonataCore/.. without registred bundle. In updated temples you can find something like this:

this is not about flashmessage anymore, this is another bug, but I don't know what it concerns

All sonatacore files are using in AdminBundle and PageBundle. This files was move to SonataAdminBundle, (SonataPageBundle require SonataAdminBundle) and will be install by EventListener on assets:install to sonatacore directory.

it looks like it wasn't done everywhere
https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/DependencyInjection/Configuration.php#L396

okej, but I have an another bug:
There are no registered paths for namespace "SonataCore".
but I don't know from what is.

It mean you using @SonataCore/.. without registred bundle. In updated temples you can find something like this:

this is not about flashmessage anymore, this is another bug, but I don't know what it concerns

Mybe you use it in twig?:

twig:
    form_themes:
        - '@SonataCore/Form/datepicker.html.twig'
        // Replace it to:
        - '@SonataForm/Form/datepicker.html.twig'

All sonatacore files are using in AdminBundle and PageBundle. This files was move to SonataAdminBundle, (SonataPageBundle require SonataAdminBundle) and will be install by EventListener on assets:install to sonatacore directory.

it looks like it wasn't done everywhere
https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/DependencyInjection/Configuration.php#L396

It is done correctly. SonataCoreBundle asssets was move to SonataAdminBundle. After call assets:install this file will be move to sonatacore, not to sonataadmin.

@axzx

SonataCoreBundle it is optional now. Read this

You should register SonataTwigBundle by add this line to your bundles.php:

Sonata\Twig\Bridge\Symfony\SonataTwigBundle::class => ['all' => true],

or you can add (not recommended) to composer to keep this bundle in your project:

"sonata-project/core-bundle": "^3.20",

I have the same problem.

Unable to find one of the following templates: "@SonataCore/FlashMessage/render.html.twig", "@SonataTwig/FlashMessage/render.html.twig" in @SonataAdmin/standard_layout.html.twig at line 331.

adding lines - does not work
Sonata\Twig\Bridge\Symfony\Bundle\SonataTwigBundle::class => ['all' => true],

Symfony -version=lts, fresh install

another error

The service "twig" has a dependency on a non-existent service "sonata.doctrine.model.adapter.chain".

@axzx missing SonataDoctrineBundle registration
@minolone You register deprecated SonataTwigBundle.

Can you add this:

    Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle::class => ['all' => true],
    Sonata\Form\Bridge\Symfony\SonataFormBundle::class => ['all' => true],
    Sonata\Twig\Bridge\Symfony\SonataTwigBundle::class => ['all' => true],

I'm using it in sandbox and it works.

@axzx missing SonataDoctrineBundle registration
@minolone You register deprecated SonataTwigBundle.

Can you add this:

    Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle::class => ['all' => true],
    Sonata\Form\Bridge\Symfony\SonataFormBundle::class => ['all' => true],
    Sonata\Twig\Bridge\Symfony\SonataTwigBundle::class => ['all' => true],

I'm using it in sandbox and it works.

Thx, it works

@wbloszyk thank you:)

I can see how much work has been done, but some migration instruction could be useful :)

Can you add this:

    Sonata\Doctrine\Bridge\Symfony\Bundle\SonataDoctrineBundle::class => ['all' => true],
    Sonata\Form\Bridge\Symfony\SonataFormBundle::class => ['all' => true],
    Sonata\Twig\Bridge\Symfony\SonataTwigBundle::class => ['all' => true],

I'm using it in sandbox and it works.

@wbloszyk Shouldn't this be automatically added ?

Let鈥檚 keep the Issue open until the recipe is updated then.

I think these recipes can't be added because the rules for the recipes repository are rejecting a recipe of this kind:
See https://github.com/symfony/recipes#creating-recipes:

Note

Don't create a recipe for Symfony bundles if the only configuration in the manifest is the registration of the bundle for all environments, as this is done automatically.

BTW, there is a previous attempt: symfony/recipes-contrib#841.

The only recipe I was able to add is for "sonata-project/form-extensions": https://github.com/symfony/recipes-contrib/pull/975.
I think we could also add a recipe for "sonata-project/twig-extensions", but we should change the package type before (and I don't know if that is completely right, since the bundle contained in that package is just part of a bridge).
See the comments at PR for more details.

Got the same issue, thanks for help.
Shouldn't the documentation be updated too ?

https://github.com/sonata-project/SonataAdminBundle/blob/master/docs/getting_started/installation.rst

A complete mess !!!

A complete mess !!!

Why? The problem is Sonata do not longer require CoreBundle. People should add it by own or register extensions instead. It should be obvius for people WHO read composer notes.

https://github.com/sonata-project/SonataAdminBundle/issues/6173#issuecomment-651108601

Got the same issue, thanks for help.
Shouldn't the documentation be updated too ?

https://github.com/sonata-project/SonataAdminBundle/blob/master/docs/getting_started/installation.rst

This seems to be a nice idea, do you want to make a PR @romainjanvier ?

add this worked for me thnks
SonataDoctrineBridgeSymfonyBundleSonataDoctrineBundle::class => ['all' => true],
SonataFormBridgeSymfonySonataFormBundle::class => ['all' => true],
SonataTwigBridgeSymfonySonataTwigBundle::class => ['all' => true],

Was this page helpful?
0 / 5 - 0 ratings