I keep running into the same issue with the sonata-project/page-bundle. When trying to add a new child block to a container block from a Sonata Admin page I get an error. This only happens when I'm trying to add a child using the "Add new" ajax button on the container's admin page - if I add a new block using the block creation action and set the container as a parent it works perfectly. I've also never had this issue with older versions of Sonata, but I need to upgrade to 3 at this point for various reasons.
If I go to the URL that the ajax button points to I get a "You cannot create a block without a page" error. It seems to be bugging out on line 84 of vendor/sonata-project/page-bundle/Controller/BlockAdminController.php:
if (!$this->admin->getParent() && get_class($this->admin) !== $sharedBlockAdminClass) {
throw new PageNotFoundException('You cannot create a block without a page');
}
The main difference I can see between this ajax call and creating a new block through it's own admin page is the admin code passed to the configure function on line 975 of vendor/sonata-project/admin-bundle/controller/CRUDController.php via the request query string '_sonata_admin'. If I force them to be identical I still get other errors from the ajax call so I assume it's probably not this and I've just missed some key configuration somewhere.
I haven't extended pages beyond what easy-extends gives me and I haven't created any custom blocks.
My complete composer require is as follows:
"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"
My sonata_pages config (aside from changing FakeBundleName) is as follow:
# 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: ~
My sonata_block config is as follows:
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:
Happy to provide any other config files that might be relevant. Any help would be greatly appreciated! This is my first SO question, let me know if I've missed anything and I'll provide it as soon as possible.