本文整理匯總了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);
}