Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Routing / Drupal7 / Router.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\drupalmoduleupgrader\Converter\Routing\Drupal7\Router.
6  */
7
8 namespace Drupal\drupalmoduleupgrader\Routing\Drupal7;
9
10 use Drupal\drupalmoduleupgrader\Routing\RouterBase;
11
12 /**
13  * Represents a collection of Drupal 7 routes, i.e., the result of hook_menu().
14  */
15 class Router extends RouterBase {
16
17   /**
18    * Gets all items of a specific type.
19    *
20    * @param string $link_types
21    *  The link type(s), separated by commas (e.g., 'MENU_NORMAL_ITEM, MENU_LOCAL_TASK').
22    *
23    * @return static
24    */
25   public function ofType($link_types) {
26     $link_types = array_map('trim', explode(', ', $link_types));
27
28     return $this->filter(function(RouteWrapper $route) use ($link_types) {
29       return in_array($route['type'], $link_types);
30     });
31   }
32
33   /**
34    * Gets all items which expose a link of any kind.
35    *
36    * @return static
37    */
38   public function getAllLinks() {
39     return $this->filter(function(RouteWrapper $route) {
40       return $route->hasLink();
41     });
42   }
43
44   /**
45    * Gets all normal links.
46    *
47    * @return static
48    */
49   public function getLinks() {
50     return $this->filter(function(RouteWrapper $route) {
51       return $route->isLink();
52     });
53   }
54
55   /**
56    * Gets all local tasks.
57    *
58    * @return static
59    */
60   public function getLocalTasks() {
61     return $this->filter(function(RouteWrapper $route) {
62       return $route->isLocalTask();
63     });
64   }
65
66   /**
67    * Gets all default local tasks.
68    *
69    * @return static
70    */
71   public function getDefaultLocalTasks() {
72     return $this->filter(function(RouteWrapper $route) {
73       return $route->isDefaultLocalTask();
74     });
75   }
76
77   /**
78    * Gets all local actions.
79    *
80    * @return static
81    */
82   public function getLocalActions() {
83     return $this->filter(function(RouteWrapper $route) {
84       return $route->isLocalAction();
85     });
86   }
87
88   /**
89    * Gets all contextual links.
90    *
91    * @return static
92    */
93   public function getContextualLinks() {
94     return $this->filter(function(RouteWrapper $route) {
95       return $route->isContextualLink();
96     });
97   }
98
99 }