Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Alias.php

class Alias

Same name in this branch
  1. 11.1.x vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php \PhpParser\Node\Stmt\TraitUseAdaptation\Alias
  2. 11.1.x vendor/symfony/dependency-injection/Alias.php \Symfony\Component\DependencyInjection\Alias

Hierarchy

  • class \Symfony\Component\Routing\Alias

Expanded class hierarchy of Alias

1 file declares its use of Alias
AliasConfigurator.php in vendor/symfony/routing/Loader/Configurator/AliasConfigurator.php
23 string references to 'Alias'
AliasRepository::preloadPathAlias in core/modules/path_alias/src/AliasRepository.php
d7_url_alias.yml in core/modules/path/migrations/d7_url_alias.yml
core/modules/path/migrations/d7_url_alias.yml
DataFieldRow::buildOptionsForm in core/modules/rest/src/Plugin/views/row/DataFieldRow.php
Provide a form for setting options.
DataFieldRow::init in core/modules/rest/src/Plugin/views/row/DataFieldRow.php
Initialize the plugin.
DataFieldRow::validateOptionsForm in core/modules/rest/src/Plugin/views/row/DataFieldRow.php
Validate the options form.

... See full list

File

vendor/symfony/routing/Alias.php, line 16

Namespace

Symfony\Component\Routing
View source
class Alias {
    private array $deprecation = [];
    public function __construct(string $id) {
    }
    public function withId(string $id) : static {
        $new = clone $this;
        $new->id = $id;
        return $new;
    }
    
    /**
     * Returns the target name of this alias.
     *
     * @return string The target name
     */
    public function getId() : string {
        return $this->id;
    }
    
    /**
     * Whether this alias is deprecated, that means it should not be referenced anymore.
     *
     * @param string $package The name of the composer package that is triggering the deprecation
     * @param string $version The version of the package that introduced the deprecation
     * @param string $message The deprecation message to use
     *
     * @return $this
     *
     * @throws InvalidArgumentException when the message template is invalid
     */
    public function setDeprecated(string $package, string $version, string $message) : static {
        if ('' !== $message) {
            if (preg_match('#[\\r\\n]|\\*/#', $message)) {
                throw new InvalidArgumentException('Invalid characters found in deprecation template.');
            }
            if (!str_contains($message, '%alias_id%')) {
                throw new InvalidArgumentException('The deprecation template must contain the "%alias_id%" placeholder.');
            }
        }
        $this->deprecation = [
            'package' => $package,
            'version' => $version,
            'message' => $message ?: 'The "%alias_id%" route alias is deprecated. You should stop using it, as it will be removed in the future.',
        ];
        return $this;
    }
    public function isDeprecated() : bool {
        return (bool) $this->deprecation;
    }
    
    /**
     * @param string $name Route name relying on this alias
     */
    public function getDeprecation(string $name) : array {
        return [
            'package' => $this->deprecation['package'],
            'version' => $this->deprecation['version'],
            'message' => str_replace('%alias_id%', $name, $this->deprecation['message']),
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary
Alias::$deprecation private property
Alias::getDeprecation public function
Alias::getId public function Returns the target name of this alias.
Alias::isDeprecated public function
Alias::setDeprecated public function Whether this alias is deprecated, that means it should not be referenced anymore.
Alias::withId public function
Alias::__construct public function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal