Last active
August 29, 2015 14:01
-
-
Save EclipseGc/e07076423bee5ffd5df1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* links = { | |
* "canonical" = "/node/{node}", | |
* "delete-form" = "/node/{node}/delete", | |
* "edit-form" = "/node/{node}/edit", | |
* "version-history" = "/node/{node}/revision/{revision}", | |
* "admin-form" = "/admin/structure/whatever..." | |
* } | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MySubscriber implements EventSubscriberInterface { | |
public function __construct(EntityManager $entity_manager, LinkRelationshipManagerInterface $manager) { | |
$this->entity_manager = $entity_manager; | |
$this->manager = $manager; | |
} | |
public static function getSubscribedEvents() { | |
return array( | |
Routing::DYNAMIC => array(array('onDynamicRoute')), | |
); | |
} | |
public function onDynamicRoute() { | |
$collection = new RouteCollection(); | |
foreach($this->entity_manager->getDefinitions() as $entity_info) { | |
foreach ($entity_info['links'] as $relationship => $pattern) { | |
$relationship_plugin = $this->manager->createInstance($relationship); | |
$route = $relationships_plugin->getRoute($pattern, $entity_info); | |
} | |
$collection->addRoute($route); | |
} | |
return $collection; | |
} | |
} |
Crell
commented
May 8, 2014
That seems like a sane addition to the overall code and gives us the ability to overwrite route defaults by simply writing them at the *.routing.yml level.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment