sonata-project / SonataBlockBundle

Symfony SonataBlockBundle
https://docs.sonata-project.org/projects/SonataBlockBundle
MIT License
414 stars 142 forks source link

Config ignoring `blocks:` section #639

Open insanetron75 opened 5 years ago

insanetron75 commented 5 years ago

The sonata-block.yml config file is only reading the default_contexts no other configuration is being read.

Environment

Sonata packages

sonata-project/admin-bundle              3.49.1 3.54.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.18.1 3.18.1 Symfony SonataBlockBundle
sonata-project/cache                     1.0.7  2.0.1  Cache library
sonata-project/classification-bundle     3.9.0  3.9.0  Symfony SonataClassificationBundle
sonata-project/core-bundle               3.17.0 3.17.0 Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.5.0  2.5.0  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.3.1  1.3.1  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  1.11.1 Lightweight Exporter library
sonata-project/intl-bundle               2.6.0  2.7.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/user-bundle               4.4.0  4.5.0  Symfony SonataUserBundle

Symfony packages

symfony/http-client           v4.3.5  v4.3.5  Symfony HttpClient component
symfony/http-client-contracts v1.1.7  v1.1.7  Generic abstractions related to HTTP clients
symfony/mime                  v4.3.5  v4.3.5  A library to manipulate MIME messages
symfony/monolog-bundle        v3.4.0  v3.4.0  Symfony MonologBundle
symfony/polyfill-apcu         v1.12.0 v1.12.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-ctype        v1.12.0 v1.12.0 Symfony polyfill for ctype functions
symfony/polyfill-iconv        v1.12.0 v1.12.0 Symfony polyfill for the Iconv extension
symfony/polyfill-intl-icu     v1.12.0 v1.12.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn     v1.12.0 v1.12.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-mbstring     v1.12.0 v1.12.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56        v1.12.0 v1.12.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70        v1.12.0 v1.12.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-php72        v1.12.0 v1.12.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73        v1.12.0 v1.12.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-util         v1.12.0 v1.12.0 Symfony utilities for portability of PHP codes
symfony/security-acl          v3.0.2  v3.0.2  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle    v3.2.6  v3.2.8  Symfony SwiftmailerBundle
symfony/symfony               v3.4.32 v4.3.5  The Symfony PHP framework

PHP version

7.1

Subject

When I call $blockService->getServicesByContext('block') in my BlockAdminController I get every block, if I dump $this->contexts in the BlockServiceManager every block has both page and block contexts. If I remove default_contexts I don't get anything returned. If I removed the blocks: section but leave the default_contexts in every block is still returned. I have looked to see if there is maybe another sonata_block config section but there isn't

sonata_block.yml:

sonata_block:
    default_contexts: [page, block]
    blocks:
        # Builtin Block
        sonata.block.service.container:
            context:   [page]
        sonata.block.service.rss:
            contexts:   [page]
        sonata.block.service.menu:
            contexts:   [page]
        sonata.block.service.template:
            contexts:   [page]
        sonata.admin.block.search_result:
            contexts:   [page]
        sonata.block.service.text:
            contexts:   [page]

        # User bundle blocks
        sonata.user.block.menu:    # used to display the menu in profile pages
            contexts:   [page]
        sonata.user.block.account: # used to display menu option (login option)
            contexts:   [page]
        #custom
        ppl.page.block.richtext:
            contexts:   [page]
        app.block.basic:
            contexts:   [page, block]
        app.block.banner:
            contexts:   [page, block]

        app.block.paymentcopy:
            contexts:   [page]
        app.block.how_work:
            contexts:   [page]
        app.block.how_work_page:
            contexts:   [page]
        app.block.ambassadors:
            contexts:   [page]
        app.block.contact_info:
            contexts:   [page]
        app.block.contact_details:
            contexts:   [page]
        ppl.page.block.metatags:
            contexts:   [page]
        app.block.recent_content:
            contexts:   [admin]
        app.block.first_draw:
            contexts:   [page]
        app.block.csv_to_table:
            contexts:   [page]
        app.block.trusts:
            contexts:   [page]
        app.block.prizes_boxes:
            contexts:   [page]
        app.block.charities_of_the_week:
            contexts:   [block]
        app.block.prize_draw_calendar:
            contexts:   [block]
        app.block.prize_plan:
            contexts:   [block]

        # Enable the SonataAdminBundle block
        sonata.admin.block.admin_list:
            contexts:   [page]
core23 commented 4 years ago

This issue should be fixed in the latest stable version

If this is still present, feel free to reopen this issue

p1nGgeR commented 1 year ago

@core23 Hi, I think this bug is still not fixed. I am using v5.0.1 Contexts from sonata_block.blocks are ignored

It looks like you don't use them here or here

VincentLanglet commented 1 year ago

Can you provide a PR @p1nGgeR ?

github-actions[bot] commented 7 months 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.