You are here

class PathUtility in Drupal 7 to 8/9 Module Upgrader 8

Same name in this branch
  1. 8 src/Utility/Path/Drupal7/PathUtility.php \Drupal\drupalmoduleupgrader\Utility\Path\Drupal7\PathUtility
  2. 8 src/Utility/Path/Drupal8/PathUtility.php \Drupal\drupalmoduleupgrader\Utility\Path\Drupal8\PathUtility

Represents a Drupal 7 route path.

Hierarchy

Expanded class hierarchy of PathUtility

3 files declare their use of PathUtility
ParameterBindingTest.php in tests/src/Unit/Routing/ParameterBindingTest.php
PathUtilityTest.php in tests/src/Unit/Utility/Path/Drupal7/PathUtilityTest.php
RouteWrapper.php in src/Routing/Drupal7/RouteWrapper.php

File

src/Utility/Path/Drupal7/PathUtility.php, line 10

Namespace

Drupal\drupalmoduleupgrader\Utility\Path\Drupal7
View source
class PathUtility extends PathUtilityBase {

  /**
   * {@inheritdoc}
   */
  public static function getComponent($value) {
    return new PathComponent($value);
  }

  /**
   * Returns if the path has %wildcards or placeholders (%) in it.
   *
   * @return bool
   */
  public function isDynamic() {
    return $this
      ->hasWildcards() || $this
      ->hasPlaceholders();
  }

  /**
   * Returns if there are placeholders in the path.
   *
   * @return bool
   */
  public function hasPlaceholders() {
    return $this
      ->getPlaceholders()
      ->count() > 0;
  }

  /**
   * Returns every placeholder in the path, keyed by position.
   *
   * @return static
   */
  public function getPlaceholders() {
    return $this
      ->filter(function (PathComponent $component) {
      return $component
        ->isPlaceholder();
    });
  }

  /**
   * Returns a copy of the collection with all placeholders removed.
   *
   * @return static
   */
  public function deletePlaceholders() {
    return $this
      ->filter(function (PathComponent $component) {
      return !$component
        ->isPlaceholder();
    });
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PathUtility::deletePlaceholders public function Returns a copy of the collection with all placeholders removed.
PathUtility::getComponent public static function Returns a new path component wrapping a value. Overrides PathUtilityInterface::getComponent
PathUtility::getPlaceholders public function Returns every placeholder in the path, keyed by position.
PathUtility::hasPlaceholders public function Returns if there are placeholders in the path.
PathUtility::isDynamic public function Returns if the path has %wildcards or placeholders (%) in it.
PathUtilityBase::$_wildcard protected property The next index for getNextWildcard() to slice on.
PathUtilityBase::add public function
PathUtilityBase::contains public function
PathUtilityBase::count public function After PHP 7.2+ for count() E_WARNING will now be emitted when attempting to count() non-countable types. Ref: https://secure.php.net/manual/en/migration72.incompatible.php#migration7...
PathUtilityBase::deleteWildcards public function Returns a copy of the collection with wildcards removed.
PathUtilityBase::find public function Filters the path by a string. The filtered path will only contain components whose string representation is identical to $element.
PathUtilityBase::getNextWildcard public function Returns the next wildcard, if any.
PathUtilityBase::getParent public function Returns a PathUtilityInterface for the parent path. Overrides PathUtilityInterface::getParent
PathUtilityBase::getWildcards public function Returns every {wildcard} in the path, keyed by position.
PathUtilityBase::hasWildcards public function Returns if there are wildcards in the path. Overrides PathUtilityInterface::hasWildcards
PathUtilityBase::__construct public function Constructs a path utility. Overrides PathUtilityInterface::__construct
PathUtilityBase::__toString public function Collapses the path into a string. Overrides PathUtilityInterface::__toString