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

Preserve '/cms/routes' when using custom basepath #129

Closed kminh closed 9 years ago

kminh commented 9 years ago

Hi,

Not sure if this is a bug or is expected, but when I set basepath to something different than cms/simple the default basepath for cmf_routing got removed.

I would like to keep cms/routes just like how cms/routes and cms/simple live together when both bundles are active.

Please advise. Thank you.

benglass commented 9 years ago

@kminh You can register your own initializer service which can take care of creating any paths you need

http://symfony.com/doc/current/cmf/bundles/phpcr_odm/fixtures_initializers.html#repository-initializers

kminh commented 9 years ago

@benglass thanks for replying. I know that I can register my initializer but for consistency purpose I believe it's best to leave cms/routes intact. At least setting a custom basepath should not trigger this kind of side effect unless stated somewhere in the documentation (it took me a while to figure out why cms/routes disappear).

kminh commented 9 years ago

Also, if I create the path manually, how do I make the routing bundle uses it since route_basepaths will be replaced by SimpleCmsBundle? Do I need to prepend extension or write a compiler pass?

benglass commented 9 years ago

@kminh Can you explain your use case a little more in terms of why you want the cms/routes path intact? Are you using it for something? If it is not in use then I'm not sure I understand why the simple cms should create it. You can configure multiple routers that use different basepaths using the chain router and you can also use a custom candidate strategy for the existing router to dynamically determine what basepath to use to look for routes. Understanding what you are trying to accomplish would make it easier to understand why you need /cms/routes in addition to /cms/simple

dbu commented 9 years ago

hi @kminh, this seems not the expected behaviour. indeed you should keep /cms/routes, e.g. for redirect routes. did you change cmf_simple_cms.persistence.phpcr.basepath or something else? i would have expected that the RoutingBundle keeps its basepath as well. note that the basepath is for the admin (and simple cms bundle adds its base path to the route_basepaths). the RoutingBundle provides cmf_routing.dynamic.persistence.phpcr.route_basepaths - if you change that one to only /cms/simple you will eliminate the /cms/routes basepath.

can you post the configuration for all cmf bundles here if this is not the problem?

kminh commented 9 years ago

hi @dbu,

This is my current configuration for Symfony CMF:

# Cmf 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

# cmf_content:
#     persistence:
#         phpcr:
#             use_sonata_admin: true
#             content_basepath: /cms/content/pages

cmf_menu:
    persistence:
        phpcr:
            content_basepath: /cms/content
    admin_extensions:
        menu_options:
            advanced: true
    voters:
        uri-prefix: ~

# Cmf Block
cmf_block:
    persistence:
        phpcr:
            use_sonata_admin: true
            block_basepath: /cms/content/blocks

cmf_simple_cms:
    persistence:
        phpcr:
            basepath: /cms/content/pages
            document_class: Acme\Bundle\SiteBundle\Doctrine\Phpcr\Page

When I don't I set route_basepaths at all, /cms/routes does not get initialized using doctrine:phpcr:repository:init, only /cms/content/pages.

However I can only reproduce this on my setup (a Symfony CMF SE), not on a fresh Symfony CMF Sandbox installation. My active CMF bundles are:

            new Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle(),
            new Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
            new Symfony\Cmf\Bundle\SimpleCmsBundle\CmfSimpleCmsBundle(),
            new Symfony\Cmf\Bundle\BlockBundle\CmfBlockBundle(),
            new Symfony\Cmf\Bundle\MenuBundle\CmfMenuBundle(),

Another issue I have noticed (even on a Sandbox installation) is that /cms/simple will be added to the service container anyway even when I set cmf_simple_cms.persistence.phpcr.basepath to /cms/content/pages:

// app/cache/dev/appDevDebugProjectContainer.php
            'cmf_routing.dynamic.persistence.phpcr.route_basepaths' => array(
                0 => '/cms/content/pages',
                1 => '/cms/routes', // this is duplicated when I also set route_basepaths to '/cms/routes'
                2 => '/cms/simple',
                3 => '/cms/routes',
            ),

and I still see this query being generated:

 SELECT * FROM phpcr_nodes WHERE path = :path AND workspace_name = :workspace ORDER BY depth, sort_order ASC Parameters: { ':path': /cms/simple, ':pathd': /cms/simple/%, ':workspace': default }

Something is probably not right when prepending config values that are array?

Thanks for taking your time to look into this.

@benglass what David said and for consistency purpose IMO. However I think it's a different issue now.

dbu commented 9 years ago

continued in #135