本文整理汇总了PHP中Drupal\Core\Entity\EntityManagerInterface::getRouteProviders方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManagerInterface::getRouteProviders方法的具体用法?PHP EntityManagerInterface::getRouteProviders怎么用?PHP EntityManagerInterface::getRouteProviders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityManagerInterface
的用法示例。
在下文中一共展示了EntityManagerInterface::getRouteProviders方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onDynamicRouteEvent
/**
* Provides routes on route rebuild time.
*
* @param \Drupal\Core\Routing\RouteBuildEvent $event
* The route build event.
*/
public function onDynamicRouteEvent(RouteBuildEvent $event)
{
$route_collection = $event->getRouteCollection();
foreach ($this->entityManager->getDefinitions() as $entity_type) {
if ($entity_type->hasRouteProviders()) {
foreach ($this->entityManager->getRouteProviders($entity_type->id()) as $route_provider) {
// Allow to both return an array of routes or a route collection,
// like route_callbacks in the routing.yml file.
$routes = $route_provider->getRoutes($entity_type);
if ($routes instanceof RouteCollection) {
$route_collection->addCollection($routes);
} elseif (is_array($routes)) {
foreach ($routes as $route_name => $route) {
$route_collection->add($route_name, $route);
}
}
}
}
}
}
示例2: getRouteProviders
/**
* {@inheritdoc}
*/
public function getRouteProviders($entity_type)
{
return $this->entityManager->getRouteProviders($entity_type);
}