class Router in Drupal 7 to 8/9 Module Upgrader 8
Represents a collection of Drupal 7 routes, i.e., the result of hook_menu().
Hierarchy
- class \Drupal\drupalmoduleupgrader\Routing\RouterBase extends \Doctrine\Common\Collections\ArrayCollection implements RouterInterface
- class \Drupal\drupalmoduleupgrader\Routing\Drupal7\Router
Expanded class hierarchy of Router
2 files declare their use of Router
- HookMenu.php in src/
Routing/ HookMenu.php - RouterTest.php in tests/
src/ Unit/ Routing/ Drupal7/ RouterTest.php
File
- src/
Routing/ Drupal7/ Router.php, line 10
Namespace
Drupal\drupalmoduleupgrader\Routing\Drupal7View source
class Router extends RouterBase {
/**
* Gets all items of a specific type.
*
* @param string $link_types
* The link type(s), separated by commas (e.g., 'MENU_NORMAL_ITEM, MENU_LOCAL_TASK').
*
* @return static
*/
public function ofType($link_types) {
$link_types = array_map('trim', explode(', ', $link_types));
return $this
->filter(function (RouteWrapper $route) use ($link_types) {
return in_array($route['type'], $link_types);
});
}
/**
* Gets all items which expose a link of any kind.
*
* @return static
*/
public function getAllLinks() {
return $this
->filter(function (RouteWrapper $route) {
return $route
->hasLink();
});
}
/**
* Gets all normal links.
*
* @return static
*/
public function getLinks() {
return $this
->filter(function (RouteWrapper $route) {
return $route
->isLink();
});
}
/**
* Gets all local tasks.
*
* @return static
*/
public function getLocalTasks() {
return $this
->filter(function (RouteWrapper $route) {
return $route
->isLocalTask();
});
}
/**
* Gets all default local tasks.
*
* @return static
*/
public function getDefaultLocalTasks() {
return $this
->filter(function (RouteWrapper $route) {
return $route
->isDefaultLocalTask();
});
}
/**
* Gets all local actions.
*
* @return static
*/
public function getLocalActions() {
return $this
->filter(function (RouteWrapper $route) {
return $route
->isLocalAction();
});
}
/**
* Gets all contextual links.
*
* @return static
*/
public function getContextualLinks() {
return $this
->filter(function (RouteWrapper $route) {
return $route
->isContextualLink();
});
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Router:: |
public | function | Gets all items which expose a link of any kind. | |
Router:: |
public | function | Gets all contextual links. | |
Router:: |
public | function | Gets all default local tasks. | |
Router:: |
public | function | Gets all normal links. | |
Router:: |
public | function | Gets all local actions. | |
Router:: |
public | function | Gets all local tasks. | |
Router:: |
public | function | Gets all items of a specific type. | |
RouterBase:: |
protected | property | ||
RouterBase:: |
public | function |
Adds a wrapped route definition to this router. Overrides RouterInterface:: |
|
RouterBase:: |
public | function |
Completes the 'build' of this router, dispatching the 'router.built'
event to all added routes. Overrides RouterInterface:: |
|
RouterBase:: |
public | function | Constructs a RouterBase. |