symfony-cmf / routing-auto-bundle

Adding automatic route generating on top of the symfony cmf routing
https://cmf.symfony.com
14 stars 29 forks source link

Route Basepath is ignored #65

Closed awdng closed 10 years ago

awdng commented 10 years ago

I have setup AutoRouting Bundle according to: http://symfony.com/doc/master/cmf/cookbook/creating_a_cms/auto-routing.html

cmf_routing:
    chain:
        routers_by_id:
            cmf_routing.dynamic_router: 20
            router.default: 100
    dynamic:
        enabled: true
        persistence:
            phpcr:
                route_basepath: /cms/routes

cmf_routing_auto:
    mappings:
        Kuoni\BackendBundle\Document\Page:
            content_path:
                # corresponds first path unit in diagram: my-forum
                language_path:
                    provider: [specified, { path: de }]
                    exists_action: use
                    not_exists_action: create
            content_name:
                provider: [content_method, { method: getTitle }]
                exists_action: [auto_increment, { pattern: -%d }]
                not_exists_action: create

but routes don't get created in '/cms/routes' but in the root, while content gets created correctly.

php app/console doctrine:phpcr:node:dump
ROOT:
  cms:
    content:
      dies-ist-ein-test:
        47cd75c30ef5c4cd852af128884de82d:
        a36071bc40a5da292057fb4ad2dc322e:
      gsdf-gsdfg-sdfgdsfg-sdfg:
        849d0ed89ed714fefc45f8a01d5c6074:
        9cedc225c02d4fcb3ac1026ddd113665:
    routes:
    taxonomy:
    media:
      image:
  de:
    dies-ist-ein-test:
    gsdf-gsdfg-sdfgdsfg-sdfg:

I feel this could have something todo with this issue i created for the DoctrinePhpCrBundle https://github.com/doctrine/DoctrinePHPCRBundle/issues/119 (something related to the GenericInitializer class which gets the basepath as an argument)

Package Versions

symfony-cmf/content-bundle           dev-master 61d6ed1 Symfony CMF Content Bundle
symfony-cmf/core-bundle              1.0.1              Symfony CMF Core Bundle
symfony-cmf/media-bundle             dev-master d6ad6df Symfony CMF Media Bundle
symfony-cmf/menu-bundle              dev-master 22e4b71 Symfony CMF Menu Bundle
symfony-cmf/routing                  dev-master 8071fae Extends the Symfony2 routing component for dynamic routes and chaining several routers
symfony-cmf/routing-auto-bundle      dev-master c3b3a60 Bundle which automatically creates and manages routes for persisted objects
symfony-cmf/routing-bundle           dev-master dce6ad8 Symfony RoutingBundle
doctrine/phpcr-bundle                dev-master 63047af Symfony DoctrinePHPCRBundle
doctrine/phpcr-odm                   dev-master 1fea541 Object-Document-Mapper for PHPCR
phpcr/phpcr                          2.1.0              PHP Content Repository interfaces
phpcr/phpcr-utils                    1.1.0              PHP Content Repository implementation independant utilities
dantleech commented 10 years ago

The specified path provider is an absolute path, it is not relative to the routing base path. I had a PR open for 11 months for a path provider which supplied the "CMF" route base path, but I closed it because it had become stale.

But in a nutshell it would be something like:

cmf_routing_auto:
    mappings:
        Kuoni\BackendBundle\Document\Page:
            content_path:
                # corresponds first path unit in diagram: my-forum
                route_root:
                    provider: [cmf_route_path]
                    exists_action: use
                    not_exists_action: create
                locale:
                   provider: [ locale ]
                   ...
dantleech commented 10 years ago

See: https://github.com/symfony-cmf/RoutingAutoBundle/pull/12

awdng commented 10 years ago

yeah that fixed it, thanks alot. I swear the documentation didn't mention it yesterday but now it does, guess you updated ;) Nice work, thx alot