Code Monkey home page Code Monkey logo

routing-bundle's Introduction

Symfony CMF Routing Bundle

Tests Latest Stable Version License

Total Downloads Monthly Downloads Daily Downloads

This package is part of the Symfony Content Management Framework (CMF) and licensed under the MIT License.

The RoutingBundle enables the CMF Routing component as a Symfony bundle. It provides route documents for Doctrine ORM and PHPCR-ODM, as well as a controller for redirection routes.

Requirements

Documentation

For the install guide and reference, see:

See also:

Support

For general support and questions, please use StackOverflow.

Contributing

Pull requests are welcome. Please see our CONTRIBUTING guide.

Thanks to everyone who has contributed already.

License

This package is available under the MIT license.

routing-bundle's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

routing-bundle's Issues

RouteTypeType routeTypes not initialized as array

User had problem, probably with empty config.

20:56:50       kendoctor | there are some action buttons there, but do not work     
20:57:01       kendoctor | Warning: Invalid argument supplied for foreach() in C:\x         
                         | ampp\htdocs\kendoctor-content-platform\vendor\symfony-cm        
                         | f\routing-bundle\Symfony\Cmf\Bundle\RoutingBundle\Form\T        
                         | ype\RouteTypeType.php line 17      

Would be fixed by initializing referenced variable as an array.

Composer Requirements are not correct?

  Problem 1
    - Installation request for symfony-cmf/routing-bundle dev-master -> satisfiable by symfony-cmf/routing-bundle[dev-master].
    - symfony-cmf/routing-bundle dev-master requires symfony-cmf/routing >=1.1,<2.0 -> no matching package found.

Evil Hack Removal Breaks me

This commit here: symfony-cmf/routing-extra-bundle@481ea82

Seemed to of break somethings for me, I reverted to the commit before that and everything works..

Here's what happens when I'm on the master for this bundle (post the commit I'm linking to)

Fatal error: Class name must be a valid object or a string in /var/www/clients/client16/web103/redneck/vendor/symfony/symfony/src/Symfony/Component/Routing/Route.php on line 365 Call Stack: 0.0004 128624 1. {main}() /var/www/clients/client16/web103/redneck/web/app_dev.php:0 0.0241 988868 2. Symfony\Component\HttpKernel\Kernel->handle() /var/www/clients/client16/web103/redneck/web/app_dev.php:30 5.7880 22383592 3. Symfony\Bundle\FrameworkBundle\HttpKernel->handle() /var/www/clients/client16/web103/redneck/app/bootstrap.php.cache:610 5.7881 22384520 4. Symfony\Component\HttpKernel\HttpKernel->handle() /var/www/clients/client16/web103/redneck/app/bootstrap.php.cache:1559 5.7881 22384552 5. Symfony\Component\HttpKernel\HttpKernel->handleRaw() /var/www/clients/client16/web103/redneck/app/bootstrap.php.cache:1383 5.7896 22407644 6. Symfony\Component\HttpKernel\Debug\ContainerAwareTraceableEventDispatcher->dispatch() /var/www/clients/client16/web103/redneck/app/bootstrap.php.cache:1403 5.7905 22429244 7. Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() /var/www/clients/client16/web103/redneck/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php:78 5.9635 24571440 8. Symfony\Component\EventDispatcher\EventDispatcher->dispatch() /var/www/clients/client16/web103/redneck/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php:165 5.9637 24572576 9. Symfony\Component\HttpKernel\Debug\ContainerAwareTraceableEventDispatcher->doDispatch() /var/www/clients/client16/web103/redneck/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:53 5.9682 24616832 10. call_user_func() /var/www/clients/client16/web103/redneck/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php:139 5.9682 24616848 11. Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest() /var/www/clients/client16/web103/redneck/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php:139 5.9690 24618616 12. Symfony\Cmf\Component\Routing\ChainRouter->matchRequest() /var/www/clients/client16/web103/redneck/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php:76 12.7440 31734488 13. Symfony\Cmf\Bundle\RoutingExtraBundle\Routing\DynamicRouter->match() /var/www/clients/client16/web103/redneck/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php:174 12.7440 31734616 14. Symfony\Cmf\Component\Routing\DynamicRouter->match() /var/www/clients/client16/web103/redneck/vendor/symfony-cmf/routing-extra-bundle/Symfony/Cmf/Bundle/RoutingExtraBundle/Routing/DynamicRouter.php:65 12.8063 33282856 15. Symfony\Component\Routing\Matcher\UrlMatcher->match() /var/www/clients/client16/web103/redneck/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/DynamicRouter.php:199 12.8063 33283048 16. Symfony\Component\Routing\Matcher\UrlMatcher->matchCollection() /var/www/clients/client16/web103/redneck/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/UrlMatcher.php:75 12.8063 33283664 17. Symfony\Cmf\Bundle\RoutingExtraBundle\Document\Route->compile() /var/www/clients/client16/web103/redneck/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/UrlMatcher.php:110 12.8064 33283712 18. Symfony\Component\Routing\Route->compile() /var/www/clients/client16/web103/redneck/vendor/symfony-cmf/routing-extra-bundle/Symfony/Cmf/Bundle/RoutingExtraBundle/Document/Route.php:307

twig regression

the RouteAdminTest started failing with symfony/symfony@9d53905 . the template we used for testing is no longer found.

there is a change to the TwigEngine how to determine if a template exists, but i can't find anything that these tests or the Testing component would play around with twig so no clue why that used to work and does no longer. @dantleech do you have any idea?

see also the hack i did in #140 to make the tests pass again. its not strictly wrong, but weird nontheless, we should fix that test to again use a string template name.

in the sandbox, things where fixed by setting twig to stable, ending up installing v1.13.2

Probably wrong behaviour with dynamic.enabled=false

Initial sandbox configuration:

cmf_routing:
    route_basepath: /cms/routes
    chain:
        routers_by_id:
            cmf_routing.dynamic_router: 20
            router.default: 100
    dynamic:
        enabled: true
        controllers_by_type:
            demo_type: sandbox_main.controller:typeAction
        controllers_by_class:
            Sandbox\MainBundle\Document\DemoClassContent: sandbox_main.controller:classAction
            Symfony\Cmf\Bundle\RoutingBundle\Document\RedirectRoute:  cmf_routing.redirect_controller:redirectAction
            Symfony\Cmf\Bundle\BlogBundle\Document\Blog: cmf_blog.blog_controller:listAction
            Symfony\Cmf\Bundle\BlogBundle\Document\Post: cmf_blog.blog_controller:viewPostAction

        templates_by_class:
            Symfony\Cmf\Bundle\ContentBundle\Document\MultilangStaticContent: MMPGlobalServicesBundle:MultilangStaticContent:index.html.twig

        locales: %locales%

If we set dynamic.enabled=false, instead of simply removing dynamic router from chain, it throws exception
RuntimeException: The parent definition "cmf_routing.enhancer_explicit_template" defined for definition "cmf_simple_cms.enhancer_explicit_template" does not exist

If we simply comment out

#            cmf_routing.dynamic_router: 20

the exception does not happen

Fire event before RouteProvider

Is there an event I can create a listener for that is loaded before the RouteProvider?

I need to load an SQLFilter before the RouteProvider. At the moment I am listening to onKernelRequest but it does not load before the RouteProvider. I tried priority -255.

    vivo_site.listener.site_aware_filter:
        class: Vivo\SiteBundle\EventListener\SiteAwareFilterListener
        arguments:
            - @vivo_site.context.site
            - @doctrine.orm.default_entity_manager
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 0 }

can we refactor RaindropRoutingBundle into this bundle to get ORM routes?

i stumbled over https://github.com/raindropdevs/RaindropRoutingBundle which is built on this bundle, but providing ORM stuff for the routing. at least the generic orm routing would be very cool to have in the cmf bundle directly.

i don't know yet if there are things in that bundle that go beyond what the cmf routing bundle can do - we should check and decide if everything is of general use or not.

/cc @erivello @matteocaberlotto

and btw, there are quite some forks (in the old sense of the word, not working copies) of other things in the raindropdevs organization. wonder if those are needed or could be merged back to their sources.

Is the IdPrefixListener really needed

I started to work on a simple multi site bundle. The main idea is to have the sites direclty below /cms and have routes, content etc. as descendants of each site. For menu repository and route repository I can set the prefix based on the site (which is selected based on the host in a listener).

But this does not work for the IdPrefixListener when you want to generate Urls cross-site (the routes of the other site would have the wrong id prefix!).

So first I came up with referencing the site in each Route but realised that it is already (indirectly referenced through the parent). Currently I use this code, which would make the IdPrefixListener obsolete in all cases (not only multi site):

public function getStaticPrefix()
{
    return $this->generateStaticPrefix($this->id, $this->getRoutesRoot()->getId());
}

/**
 * return the first parent that is not instance of a route
 */
protected function getRoutesRoot()
{
    $root = $this;
    while ($root && $root instanceof \Symfony\Component\Routing\Route) {
        $root = $root->getParent();
    }
    return $root;
}

If we used a "RouteDirectory" document as discussed before the class check could check for that document.

improve logging on routing failures

currently i end up having to debug DynamicRouter and RouteRepository quite frequently to figure out issues in the routing. we should instead ensure that sufficient information is available inside the profiler.

investigate if we can get rid of the minimal admins

if we find a way to detect in an admin if its embedded or not and conditionally add the fields if needed, we would reduce our amount of classes and services. maybe Admin::$parent or Admin::$parentFieldDescription would indicate that? or maybe there is something else to know it. then we could drop all minimal admins and integrate both in the normal admin class, but just add the additional fields if its not embedded. would you want to investigate if we can determine if this is an embedded admin or not?

follow up of #71

/cc @EmmanuelVella

add support for relating routes by locale

this should then be used during URL generation if a different locale is supplied.

# cmf_routing_dynamic_route_cms_routes_en points to a route with requirement '_locale' = 'en'
# but it also has references to cmf_routing_dynamic_route_cms_routes_de with requirement '_locale' = 'de'
# therefore the below call should actually generate the url for cmf_routing_dynamic_route_cms_routes_de
$router->generate('cmf_routing_dynamic_route_cms_routes_en', array('_locale' => 'de'));

Automatic generation of routes

Add easy way to automatically manage routes for Documents, e.g.

  1. When a new document is persisted a route should be automatically created.
  2. When a document is updated its corresponding route should be updated (e.g. doc:title > route:nodeName).
  3. When a route is removed the corresponding route should be removed / deactivated.

Incompatibilty with JMSI18nRoutingBundle

Hi,

Both this bundle and the JMSI18nRoutingBundle replace the router alias with their own. I would expect it to be down to the bundle load order that would determine which 'router' alias is replaced last.

However, since JMSI18nRoutingBundle does it in a compiler pass, it will replace your alias regardless of bundle load order (as the MergeExtensionConfigurationPass always runs first).

Could your own alias replacement be moved to a compiler pass, so bundle load order is respected?

I'll submit a PR if you would be happy with this change.

Cheers

support for route _locale

we could add support to make the first url segment be matched as {_locale} to reduce the redundancy when creating a route object. then the admin would not need to require the locale option anymore. and the admin should not require it anyways as right now its impossible to create non-locale routes.

it is more complicated than what we do in SimpleCmsBundle as we still want to namespace the route documents by locale https://github.com/symfony-cmf/SimpleCmsBundle/blob/master/Document/MultilangRoute.php#L23
so for us we would want to eat away the first segment after the prefix as this /is/ the locale, and do a requirement on _locale for that piece.

Route Enhancers

I have a use case, where in I would like to use enhancers to apply both a controller and a template. As the documentation reads, you can only do one or the other but not both. I would like to suggest that the template enhancer "check" if the _controller is set, if not it still functions as it does now, but if it is set, the template enhancer just sets _template on the route. This way we don't have to assign a template or a controller to the route.

Depend on symfony 2.1.7 minimum

because of a bug fixed in the security component (HttpUtils not aware of RequestMatcher) we should depend on symfony 2.1.7. but that is not released yet. once it is, revert 2ad0de6 which reverted 61d0421

Dynamic router database error

I have a dynamic router that is loaded which connects to the database.

I dropped the entire database and tried to run

app/console doctrine:database:create

However, it appears as though the router is trying to load even though the database does not exist and I receive a PDOException in my console. Is this my responsibility to handle the \PDOException in the router provider?

bug using Symfony CMF & RoutingExtraBundle

Hello everyone,

This morning i've got an error, maybe because something is on the road, but when i install the Symfony CMF Standalone Project i've got this error printing when i do a

$ app/console cache:clear

PHP Fatal error: Class Symfony\Cmf\Bundle\RoutingExtraBundle\Document\ContentRepository contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symfony\Cmf\Component\Routing\ContentRepositoryInterface::getContentId) in /Users/iJhon/Sites/Symfony-CMF/vendor/symfony-cmf/routing-extra-bundle/Symfony/Cmf/Bundle/RoutingExtraBundle/Document/ContentRepository.php on line 37
PHP Stack trace:
PHP 1. {main}() /Users/iJhon/Sites/Symfony-CMF/app/console:0
PHP 2. Symfony\Component\Console\Application->run() /Users/iJhon/Sites/Symfony-CMF/app/console:22
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:106
PHP 4. Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:68
PHP 5. Symfony\Component\HttpKernel\Bundle\Bundle->registerCommands() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:87
PHP 6. Symfony\Component\Console\Application->add() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Bundle/Bundle.php:193
PHP 7. Symfony\Bundle\FrameworkBundle\Command\RouterApacheDumperCommand->isEnabled() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:403
PHP 8. Symfony\Component\DependencyInjection\Container->get() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php:36
PHP 9. appDevDebugProjectContainer->getRouterService() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:262
PHP 10. Symfony\Component\DependencyInjection\Container->get() /Users/iJhon/Sites/Symfony-CMF/app/cache/dev/appDevDebugProjectContainer.php:3804
PHP 11. appDevDebugProjectContainer->getSymfonyCmfRoutingExtra_RouterService() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:262
PHP 12. Symfony\Component\DependencyInjection\Container->get() /Users/iJhon/Sites/Symfony-CMF/app/cache/dev/appDevDebugProjectContainer.php:2679
PHP 13. appDevDebugProjectContainer->getSymfonyCmfSimpleCms_DynamicRouterService() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:262
PHP 14. Symfony\Component\DependencyInjection\Container->get() /Users/iJhon/Sites/Symfony-CMF/app/cache/dev/appDevDebugProjectContainer.php:2707
PHP 15. appDevDebugProjectContainer->getSymfonyCmfSimpleCms_GeneratorService() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:262
PHP 16. Symfony\Component\DependencyInjection\Container->get() /Users/iJhon/Sites/Symfony-CMF/app/cache/dev/appDevDebugProjectContainer.php:2784
PHP 17. appDevDebugProjectContainer->getSymfonyCmfRoutingExtra_DefaultContentRepositoryService() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:262
PHP 18. Symfony\Component\ClassLoader\DebugClassLoader->loadClass() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php:0
PHP 19. require() /Users/iJhon/Sites/Symfony-CMF/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/DebugClassLoader.php:96

It's seem like something wrong with RoutingExtraBundle. Last week everything are working until my composer update of today...
I've tried using jackrabbit or DBAL at content repository but the error is the same.

$ composer update

Loading composer repositories with package information
Updating dependencies (including require-dev)

  • Updating symfony-cmf/create-bundle dev-master (d910203 => 8f3e8a8)
    Checking out 8f3e8a8cc334489637afb755c68a75bb289a8304
  • Updating jdorn/sql-formatter dev-master (248cceb => 46ec57e)
    Checking out 46ec57eb77c2aaf6e685ecb9864ac01a5878cc77
  • Updating friendsofsymfony/rest-bundle dev-master (96cfb14 => c334e61)
    Checking out c334e61def1c4665560b714d9b219011dca814a5
  • Updating symfony-cmf/block-bundle dev-master (4d65f26 => b0cf678)
    Checking out b0cf6781e5e6ad289c7855c28cef6610f3756d6c
  • Updating symfony-cmf/routing dev-master (3c1b600 => 1.0.0-b)
    Checking out 1.0.0-beta1
  • Updating doctrine/orm 2.3.x-dev (8d78b90 => ae1f903)
    Checking out ae1f903080407c97847d5bab325bba208622bb3a
  • Updating phpunit/phpunit dev-master (90bf298 => cb66925)
    Checking out cb669257d894eb4239282a89d52326d3b28d6b94

Someone can help me ?

Thanks.

Regards.

[ORM] priority versus static prefix

we need to define what wins if i have /my/{thing} and /my/specific and the priority of the route having /my as static prefix has higher priority than /my/specific

in phpcr its always the longer static prefix that wins. i propose to do the same for the orm. not sure how exactly we need to sort for that, if we have to store the number of / in a separate column to sort on that.

route documents should use _locale

have the Route document transform the locale piece of the path into {_locale} and use the locale in requirement rather than default. this should be optional behaviour - or maybe we want to do a special LocaleAwareRoute class?

needs to be coordinated with symfony-cmf/Routing#26

make choice of storage layer configurable

also make sure we have a "enabled" parameter to be used with the phpcr-odm and the orm compiler pass and that this is false if dynamicrouter is not active and the storage is not explicitly activated.

right now running the bundle in an environment where phpcr-odm of the phpcr-bundle is not activated leads to

[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]                                                                             
You have requested a non-existent parameter "None of the managerParameters (cmf_routing.manager_name, doctrine_phpcr.odm.default_document_manager) resulted in a valid name".

/routes wont be removed from urls

Hey i am using beta-1 of the symfony-cmf standard edition. and i like it very much :) thanks for the good work!

here is my problem:

nodes dump

ROOT:
  cms:
    routes:
      home:
    menu:
      home:
    content:
      static:
      home:

routing.yml

home_redirect:
    pattern: /
    defaults:
        _controller: FrameworkBundle:Redirect:redirect
        route: /cms/routes/home
        permanent: true

config.yml

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

if i try to access / in my browser i am redirected to /routes/home, that /routes/ is to much.
if i try to access /home i am getting a 404...

how to remove the routes/prefix? even if i try to set the route_basepath to /cms/routes it wont work.

any hints?

Orm RouteProvider try-catch invalid exception

we should not try-catch the phpcr-odm RepositoryException but maybe a doctrine orm exception. we also need to figure out whether we encountered an exception that should be ignored or not.

} catch (RepositoryException $e) {

Automatically add compiler pass for each document manager

When using the RoutingBundle with multiple document managers (e.g. when using multiple workspaces), I think it would be better for it to add a DoctrinePhpcrMappingsPass compiler pass for each document manager, as seen in the CmfRoutingBundle class.

Without this, a user of the bundle can run into problems where classes are not mapped correctly, e.g. when working with a document manager other than the default. See this topic for details.

Possible approaches:

  • Automatically loop through all the managers specified in doctrine_phpcr -> odm ?
  • Or a manual setting?
cmf_routing:
    dynamic:
        manager_name: published
        mapped_managers: [ preview, published ]

I don't mind doing a PR if it makes sense to change this. If not, then maybe I should update the documentation, because the user of the bundle currently needs to add similar compiler pass code into their own bundle class.

Don't distribute PHPCR Documents (or any other model classes).

I've just added RoutingExtraBundle to my project and have received the following exception:

[Doctrine\Common\Annotations\AnnotationException]                                                                                                                                                

[Semantical Error] The annotation "@Doctrine\ODM\PHPCR\Mapping\Annotations\Document" in class Symfony\Cmf\Bundle\RoutingExtraBundle\Document\Route does not exist, or could not be auto-loaded.

My project isn't going to make use of PHP-CR.

Route class not found

As discussed in this topic on symfony-cmf-devs.

In prod mode, I am currently seeing this error when attempting to clear the cache:

$ app/console cache:clear --env prod
Clearing the cache for the prod environment with debug false

  [Doctrine\ODM\PHPCR\Mapping\MappingException]
  The class 'Symfony\Cmf\Bundle\RoutingBundle\Document\Symfony\Component\Routing\Route' could not be found

also in the Apache logs when viewing a page:

PHP Fatal error:  Uncaught exception 'Doctrine\\ODM\\PHPCR\\Mapping\\MappingException' with message 'The class 'Symfony\\Cmf\\Bundle\\RoutingBundle\\Document\\Symfony\\Component\\Routing\\Route' could not be found' in /var/www/routing-issue/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php:35\nStack trace:\n#0 /var/www/routing-issue/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadataFactory.php(104): Doctrine\\ODM\\PHPCR\\Mapping\\MappingException::classNotFound('Symfony\\Cmf\\Bun...')\n#1 /var/www/routing-issue/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php(205): Doctrine\\ODM\\PHPCR\\Mapping\\ClassMetadataFactory->loadMetadata('Symfony\\Cmf\\Bun...')\n#2 /var/www/routing-issue/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadataFactory.php(87): Doctrine\\Common\\Persistence\\Mapping\\AbstractClassMetadataFactory->getMetadataFor('Symfony\\Cmf\\Bun...')\n#3 /var/www/routing-issue/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Abstrac in /var/www/routing-issue/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php on line 35

To reproduce this issue:

git clone https://github.com/fazy/demo-routing-issue
cd demo-routing-issue
composer install --dev
php app/console cache:clear --env prod

The example works in dev mode:

cd demo-routing-issue
yes | app/console doctrine:phpcr:fixtures:load
app/console doctrine:phpcr:node:dump

Then point your web server at the web directory in there and visit:
http://routing-issue/app_dev.php/my-route

This works as expected, but the following results in the error in Apache logs as mentioned above:
http://routing-issue/my-route

The problem seems to be related to this file:
https://github.com/symfony-cmf/RoutingBundle/blob/master/Resources/config/doctrine/Symfony.Component.Routing.Route.phpcr.xml

Removing the file stops the error on cache:clear, but unfortunately also stops the route from loading (in dev or prod mode), so it's obviously needed. :)

Problem using dashes in route path

Hi all,

I encounter problems fetching a route document by the route name when the route contains dashes.

Summary

The route name of the route /netvlies/routes/about-us is cmf_routing_dynamic_route_netvlies_routes_about_us. When generating a path by the route name, the name will be resolved to /netvlies/routes/about/us.

Full description

Our phpcr repository contains the following route /netvlies/routes/about-us. When requesting this route (/app_dev.php/about-us) the route is found within the dynamic router logic and the route name is attached to the request (the _route key).

The router name (value of key _route) is cmf_routing_dynamic_route_netvlies_routes_about_us. The route name is generated in the method findManyByUrl of class Symfony\Cmf\Bundle\RoutingExtraBundle\Document\RouteRepository by the following lines of code

$this->routeNamePrefix . preg_replace('/[^a-z0-9A-Z_.]/', '_', $key);

As said above this results in cmf_routing_dynamic_route_netvlies_routes_about_us.

When I use the router to generate a path by the route:

 $this->container->get('router')->generate('cmf_routing_dynamic_route_netvlies_routes_about_us');

This results in an exception:

An exception has been thrown during the rendering of a template ("None of the chained routers were able to generate route "cmf_routing_dynamic_route_netvlies_routes_about_us".")

I found that this is caused by the following lines of code in getRouteByName of the RouteRepository class:

$path = str_replace('_', '/', substr($name, strlen($this->routeNamePrefix)));
$route = $this->dm->find($this->className, $path);

In this case the value of $path will be /netvlies/routes/about/us. Since there is no route with that path an exception is thrown.

I have tried to add the dash to the preg_replace so that the route name would be cmf_routing_dynamic_route_netvlies_routes_about-us but the dash is not allowed by the Symfony Route component.

Dynamic dependency on controller_resolver

Hello,

RouteAdmin relies on controller_resolver service that is in fact not public. Due to this exception is thrown during validation saying You have requested a non-existent service "controller_resolver".
Is it just me or code is really broken? If it's not only me I can provide a fix for this.

Regards,
Alex

Class Symfony\Cmf\Bundle\RoutingBundle\Document\Route contains 1 abstract method and must therefore be declared abstract...

Hello, I'n trying to install Symfony CMF.
When I try to load the demo fixtures to generate the routes, I get the following message:

PHP Fatal error: Class Symfony\Cmf\Bundle\RoutingBundle\Document\Route contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symfony\Cmf\Component\Routing\RouteObjectInterface::getContent) in /opt/local/apache2/htdocs/uma/dev2/sites/php/symfony-cmf/vendor/symfony-cmf/routing-bundle/Symfony/Cmf/Bundle/RoutingBundle/Document/Route.php on line 402

Googling this didn't provide much help, except pointing me to a imilar issue: #74

Is there a way I can fix this?

Thanks in advance
pcruz

More generic name for the Form Type

The form type is very useful, but I feel the name is a bit too specific.

"symfony_cmf_routing_extra_terms_form_type"

Often you may have one or more checkboxes e.g.

[ ] I have read the "Privacy Policy"
[ ] I agree to the "Terms"
[ ] I agree to the "User Charter"

How about something like:

"symfony_cmf_routing_extra_checkbox_url_label_form_type"
or similar?

This also reveals the fact the input is a checkbox, and indicates someting special about url and label.

What are other peoples thoughts?

use mapped superclass for route

http://pastebin.com/VyLVZbmB => get rid of the

protected $hostnamePattern;

we probably should fix phpcr-odm to refuse persisting mappedsuperclass to the db. currently it just treats them like normal documents.

actually it could make sense to also be able to store core symfony routes directly - but we would need a different mapping than we use when we use it as base class of our route document

Monolog-bundle dev-master requirement

Is there any specific reason why dev-master is required for monolog? It prevents from removing global minimum-stability: dev in a project using routing-extra-bundle. Wouldn't 2.1.* be enough for monolog?

route tree per hostname

see #32: support a route tree where we get the hostname from a tree element, allowing to use a route tree per host handled by this site

route->getRequirement fails for proxy classes

getRequirement is declared in Symfony core and our odm proxy generation ignores parent methods, so getRequirement('_locale') (or whatever) fails when the proxy is not initialized in another way ...

Should we add parent methods to our proxy generation?

Complete polish translation

in #157 we added new translated things that need to be translated into polish.

  <trans-unit id="form.label_add_format_pattern">
    <source>form.label_add_format_pattern</source>
    <target>Add format pattern</target>
  </trans-unit>
  <trans-unit id="form.label_add_trailing_slash">
    <source>form.label_add_trailing_slash</source>
    <target>Add trailing slash</target>
  </trans-unit>

/cc @emgiezet

Doctrine manager register

I just noticed the config has updated so that "manager_registry" was moved under the "phpcr_provider" node.

If I don't set my manager_register to "doctrine" I get errors.

Here is what I had:

cmf_routing:
    chain:
        routers_by_id:
            cmf_routing.dynamic_router: 20
            router.default: 100
    dynamic:
        enabled: true
        route_provider_service_id: vivo_page.routing.provider
        manager_registry: doctrine

I have updated it so that it is now:

cmf_routing:
    chain:
        routers_by_id:
            cmf_routing.dynamic_router: 20
            router.default: 100
    dynamic:
        enabled: true
        route_provider_service_id: vivo_page.routing.provider
        phpcr_provider:
            manager_registry: doctrine

And it works again. However, why is the manager register under a phpcr node if its not related to phpcr?

If I don't set a manager_register I get the following error:

 [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]                            
  The service "cmf_routing.generator" has a dependency on a non-existent service "cmf_routing.content_  
  repository". 

fix tests

looks like some change in symfony core lead to the tests failing. not sure if the bundle will still work in current master of symfony.

@lsmith77 do you know if there where changes to the way DI and scope works? we get lots of " You cannot create a service ("request") of an inactive scope ("request")."

Get Router Matcher

I am trying to create a RouteValidator. I have a validator for validating a Route for the Symfony Router. However, it fails for the CMF Routing because there isn't a getMatcher method. Is there a way I can check if a route is already taken?

https://gist.github.com/trsteel88/5572570

fyi, I tried using the match method (https://github.com/symfony-cmf/RoutingBundle/blob/master/Routing/DynamicRouter.php#L65). However, a exception is thrown if there is no match. Is this normal?

Catchable Fatal Error: Argument 1 passed to Symfony\Cmf\Bundle\RoutingExtraBundle\Routing\DynamicRouter::matchRequest() must be an instance of Symfony\Component\HttpFoundation\Request, null given, called in /usr/local/zend/apache2/htdocs/vivogroup/cms-dev/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php on line 168 and defined in /usr/local/zend/apache2/htdocs/vivogroup/cms-dev/vendor/symfony-cmf/routing-extra-bundle/Symfony/Cmf/Bundle/RoutingExtraBundle/Routing/DynamicRouter.php line 72

I am using the dynamic router:

symfony_cmf_routing_extra:
    chain:
        routers_by_id:
            symfony_cmf_routing_extra.dynamic_router: 20
            router.default: 100
    dynamic:
        enabled: true
        route_provider_service_id: vivo_page.routing.provider
        manager_registry: doctrine
        content_repository_service_id: vivo_page.routing.content_repository

Allow using different document managers for creating and viewing routes

I am using separate preview and published workspaces and this seems to cause an issue when using the RoutingBundle.

Given a route created with code like this:

$route = new Route;
$route->setPosition($parentNode, $newNodeName);
$route->setDefault('_controller', 'PwnContentViewBundle:Default:index');
$route->setRouteContent($sourceNode);
$this->manager->persist($route);
$this->manager->flush();

with the following config:

symfony_cmf_routing:
    dynamic:
        enabled: true
        manager_registry: doctrine_phpcr
        manager_name: preview
        routing_repositoryroot: /sms/site/routes
    chain:
        routers_by_id:
            symfony_cmf_routing.dynamic_router: 200
            router.default: 100

I find nodes like the following are created:

about:
  - addTrailingSlash =
  - jcr:uuid = 8cc1ea67-24b2-458d-9baf-dceacf739925
  - routeContent =
   - uuid: da6fe0cb-121c-41e5-bca3-ee5a6067974c
  - jcr:mixinTypes = Array(    [0] => phpcr:managed    [1] => mix:referenceable)
  - defaults = Array(    [0] => ContentViewBundle:Default:index)
  - jcr:primaryType = nt:unstructured
  - phpcr:class = Symfony\Cmf\Bundle\RoutingBundle\Document\Route
  - phpcr:classparents = Array(    [0] => Symfony\Component\Routing\Route)
  - requirements = Array()
  - defaultsKeys = Array(    [0] => _controller)
  - host =
  - addFormatPattern =
  - options = Array()

This works fine with one workspace, but when there are two workspaces I need to change the following config after loading the fixtures in order to view the site:

symfony_cmf_routing:
    dynamic:
        manager_name: published # (was preview)

Note that keeping this permanently set to published doesn't work. Even though my fixtures code loads into the right workspace, something in the route creation causes the following properties to be missed if the above workspace doesn't match my fixtures:

  - phpcr:class = Symfony\Cmf\Bundle\RoutingBundle\Document\Route
  - phpcr:classparents = Array(    [0] => Symfony\Component\Routing\Route)

At the moment I can think of a couple of solutions:

  • I could create my own RouteProvider service that sets the desired (published) document manager, then tell RoutingBundle to use it. In fact, I have just tried this but it looks like not only the Route Provider needs to know about the published workspace. I end up with this error: "Unable to find the controller for path "/about". Maybe you forgot to add the matching route in your routing configuration?"
  • Maybe there should be separate config items for the manager to use when creating routes and using routes? It would require finding all the usages of document manager and deciding which config they should pick up.

See also PR #54 in BlockBundle where a similar (but not similar enough!) issue was resolved.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.