Sonata页面包3.0无法将子块添加到容器块

时间:2016-06-28 05:27:01

标签: php symfony sonata

我一直在使用sonata-project / page-bundle遇到同样的问题。尝试从Sonata Admin页面向容器块添加新的子块时,出现错误。这种情况只发生在我尝试使用"添加新的"容器管理页面上的ajax按钮 - 如果我使用块创建操作添加新块并将容器设置为父级,则它可以完美地工作。我对旧版Sonata也没有遇到过这个问题,但由于各种原因,我现在需要升级到3。

如果我转到ajax按钮指向的URL,我会得到一个"你不能创建一个没有页面的块"错误。它似乎是在供应商/ sonata-project / page-bundle / Controller / BlockAdminController.php的第84行上发布的:

if (!$this->admin->getParent() && get_class($this->admin) !== $sharedBlockAdminClass) {
    throw new PageNotFoundException('You cannot create a block without a page');
}

我可以在这个ajax调用和通过它自己的管理页面创建一个新块之间看到的主要区别是传递给vendor / sonata-project / admin-bundle /的第975行的configure函数的管理代码controller / CRUDController.php通过请求查询字符串' _sonata_admin'。如果我强迫它们相同,我仍然会从ajax调用中得到其他错误,所以我认为它可能不是这个而且我在某处错过了一些关键配置。

我还没有超出easy-extends给我的页面,我还没有创建任何自定义块。

我的完整作曲家要求如下:

    "php": ">=5.3.9",
    "symfony/symfony": "~2.5",
    "doctrine/orm": "~2.2,>=2.2.3",
    "doctrine/doctrine-bundle": "~1.2",
    "doctrine/doctrine-fixtures-bundle": "2.3.0",
    "symfony/assetic-bundle": "~2.3",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~4.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",

    "sonata-project/core-bundle": "^3.0",
    "sonata-project/exporter": "~1.0",
    "sonata-project/admin-bundle": "^3.0",
    "sonata-project/block-bundle": "^3.0",
    "sonata-project/page-bundle": "^3.0",
    "sonata-project/media-bundle": "^3.0",
    "sonata-project/classification-bundle": "^3.0",
    "sonata-project/doctrine-orm-admin-bundle": "^3.0",
    "sonata-project/easy-extends-bundle": "^2.1.10",
    "sonata-project/user-bundle": "^3.0",
    "sonata-project/datagrid-bundle": "^2.2",
    "sonata-project/cache-bundle": "^2.1.7",

    "raulfraile/ladybug-bundle": "~1.0",

    "gedmo/doctrine-extensions": "2.3.12",
    "geoip2/geoip2": "~2.0",
    "jms/serializer-bundle": "~0.11",
    "egeloen/ckeditor-bundle": "4.0.3",

    "knplabs/knp-menu-bundle": "^2.0",
    "symfony/var-dumper": "^3.1",
    "cocur/slugify": "1.4.1",
    "pixassociates/sortable-behavior-bundle": "^1.0",
    "stof/doctrine-extensions-bundle": "^1.2",
    "friendsofsymfony/elastica-bundle": "^3.1",

    "stackla/stackla-php-sdk": "~1.1",
    "peekmo/jsonpath": "dev-master"

我的sonata_pages配置(除了更改FakeBundleName)如下:

# Dynamic router configuration    
cmf_routing:
    chain:
        routers_by_id:
            sonata.page.router: 150
            router.default: 100

sonata_page:
    slugify_service:   sonata.core.slugify.cocur # old BC value is sonata.core.slugify.native
    multisite: host
    use_streamed_response: true # set the value to false in debug mode or if the reverse proxy does not handle streamed response
    ignore_route_patterns:
        - ^(.*)admin(.*)   # ignore admin route, ie route containing 'admin'
        - ^_(.*)          # ignore symfony routes

    ignore_routes:
        - sonata_page_cache_esi
        - sonata_page_cache_ssi
        - sonata_page_js_sync_cache
        - sonata_page_js_async_cache
        - sonata_cache_esi
        - sonata_cache_ssi
        - sonata_cache_js_async
        - sonata_cache_js_sync
        - sonata_cache_apc

    ignore_uri_patterns:
        - ^/admin\/   # ignore admin route, ie route containing 'admin'

    page_defaults:
        homepage: {decorate: false} # disable decoration for homepage, key - is a page route

    default_template: default # template key from templates section, used as default for pages
    templates:
        default:
            path: 'FakeBundleName::standard_page.html.twig'
            name: 'default'
            containers:
                content:
                    name: Main content
            matrix:
                layout: |
                    CCCCCCCC

                mapping:
                  C: content

    direct_publication: false # or %kernel.debug% if you want to publish in dev mode (but not in prod)

    # manage the http errors
    catch_exceptions:
        not_found: [404]    # render 404 page with "not_found" key (name generated: _page_internal_error_{key})
        fatal:     [500]    # so you can use the same page for different http errors or specify specific page for each error


# Enable Doctrine to map the provided entities
doctrine:
    orm:
        entity_managers:
            default:
                mappings:
                    ApplicationSonataPageBundle: ~
                    SonataPageBundle: ~

我的sonata_block配置如下:

sonata_block:
    default_contexts: [sonata_page_bundle]
    context_manager: sonata.page.block.context_manager
    blocks:
        sonata.admin.block.admin_list:
            contexts: [admin]

        sonata.block.service.text:
        sonata.block.service.rss:

很高兴提供可能相关的任何其他配置文件。任何帮助将不胜感激!这是我的第一个问题,如果我错过任何内容,请告诉我,我会尽快提供。

0 个答案:

没有答案