symfony-cmf / simple-cms-bundle

UNMAINTAINED - A more-than-simple cms based on the cmf components
http://cmf.symfony.com/
49 stars 45 forks source link

Exception when persisting new Page document #135

Closed kminh closed 9 years ago

kminh commented 9 years ago

Hi,

I have the following configuration:

cmf_core:
    persistence:
        phpcr: true
    publish_workflow:
        enabled:                 true
        checker_service:         cmf_core.publish_workflow.checker.default
        view_non_published_role: ROLE_CAN_VIEW_NON_PUBLISHED
        request_listener:        true
    sonata_admin:
        extensions:
            publishable:
                form_group: form.group.publish_workflow
            publish_time:
                form_group: form.group.publish_workflow
            translatable:
                form_group: form.group_general

# Cmf Routing Configuration
cmf_routing:
    dynamic:
        persistence:
            phpcr:
                route_basepaths:
                    - /cms/routes
                content_basepath: /cms/content

cmf_simple_cms:
    persistence:
        phpcr:
            basepath: /cms/content/pages
            document_class: Acme\AcmeBundle\Doctrine\Phpcr\Page # this one extends SimpleCmsBundle's Page model

cmf_block:
    persistence:
        phpcr:
            block_basepath: /cms/content/blocks

cmf_menu:
    persistence:
        phpcr:
            content_basepath: /cms/content

and I also use a compiler pass to change the admin class of SimpleCmsBundle's page:

class SymfonyCmfSimpleCmsCompilerPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        $definition = $container->getDefinition('cmf_simple_cms.persistence.phpcr.admin.page');
        $definition->setClass('Acme\AcmeBundle\Admin\PageAdmin');
    }
}

When I try to create a new Page, I get this error message: Can not determine the prefix. Either this is a new, unpersisted document or the listener that calls setPrefix is not set up correctly. which comes from https://github.com/symfony-cmf/RoutingExtraBundle/blob/master/Document/Route.php#L231

setPrefix was never called I suppose. Any ideas?

Thanks.

dbu commented 9 years ago

hi,

this should work i think. but we seem to have an issue with the base paths. can you try adding /cms/content/pages to the routing configuration to see if that is the problem? so that the routing config looks as follows:

cmf_routing:
    dynamic:
        persistence:
            phpcr:
                route_basepaths:
                    - /cms/routes
                    - /cms/content/pages

simple cms pages are route and content in one. as long as you do not need multilanguage or other ways of varying urls for the same content, or a menu structure different from the content structure, they are a good choice as they are simple to use.

kminh commented 9 years ago

That seems to make the exception disappear.

But shouldn't /cms/content/pages be added automatically to route_basepaths via extension?

Somewhat related to https://github.com/symfony-cmf/SimpleCmsBundle/issues/129, in appDevDebugProjectContainer.php I see:

            'cmf_routing.dynamic.persistence.phpcr.route_basepaths' => array(
                0 => '/cms/routes',
                1 => '/cms/content/pages',
                2 => '/cms/routes',
                3 => '/cms/simple',
                4 => '/cms/routes',
                5 => '/cms/content/pages'
            ),

if I add /cms/content/pages as you suggested.

dbu commented 9 years ago

good, so at least it works. i guess we really need to revisit this in the RoutingBundle. i created https://github.com/symfony-cmf/RoutingBundle/issues/290 - if you have time to help us there, that would be great! if not i will try to find some time to look into this.