You are here

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\Drupal7
View 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

Namesort descending Modifiers Type Description Overrides
Router::getAllLinks public function Gets all items which expose a link of any kind.
Router::getContextualLinks public function Gets all contextual links.
Router::getDefaultLocalTasks public function Gets all default local tasks.
Router::getLinks public function Gets all normal links.
Router::getLocalActions public function Gets all local actions.
Router::getLocalTasks public function Gets all local tasks.
Router::ofType public function Gets all items of a specific type.
RouterBase::$dispatcher protected property
RouterBase::addRoute public function Adds a wrapped route definition to this router. Overrides RouterInterface::addRoute
RouterBase::finalize public function Completes the 'build' of this router, dispatching the 'router.built' event to all added routes. Overrides RouterInterface::finalize
RouterBase::__construct public function Constructs a RouterBase.