function PathAliasExists::doEvaluate

Check if a path alias exists.

Parameters

string $alias: The alias to see if exists.

\Drupal\Core\Language\LanguageInterface|null $language: The language to use.

Return value

bool TRUE if the system path does not match the given alias (ie: the alias exists).

File

src/Plugin/Condition/PathAliasExists.php, line 86

Class

PathAliasExists
Provides a 'Path alias exists' condition.

Namespace

Drupal\rules\Plugin\Condition

Code

protected function doEvaluate($alias, LanguageInterface $language = NULL) {
    $langcode = is_null($language) ? NULL : $language->getId();
    $path = $this->aliasManager
        ->getPathByAlias($alias, $langcode);
    // getPathByAlias() returns the alias if there is no path.
    return $path != $alias;
}