You are here

class LanguageSwitchLinksAlterEvent in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/core_event_dispatcher/src/Event/Language/LanguageSwitchLinksAlterEvent.php \Drupal\core_event_dispatcher\Event\Language\LanguageSwitchLinksAlterEvent

Class LanguageSwitchLinksAlterEvent.

Hierarchy

Expanded class hierarchy of LanguageSwitchLinksAlterEvent

2 files declare their use of LanguageSwitchLinksAlterEvent
core_event_dispatcher.module in modules/core_event_dispatcher/core_event_dispatcher.module
Core event dispatcher submodule.
LanguageSwitchLinksAlterEventTest.php in modules/core_event_dispatcher/tests/src/Unit/Language/LanguageSwitchLinksAlterEventTest.php

File

modules/core_event_dispatcher/src/Event/Language/LanguageSwitchLinksAlterEvent.php, line 13

Namespace

Drupal\core_event_dispatcher\Event\Language
View source
class LanguageSwitchLinksAlterEvent extends Event implements EventInterface {

  /**
   * The links array.
   *
   * @var array
   */
  private $links;

  /**
   * The language type.
   *
   * @var string
   */
  private $type;

  /**
   * The request path.
   *
   * @var \Drupal\Core\Url
   */
  private $path;

  /**
   * LanguageSwitchLinksAlterEvent constructor.
   *
   * @param array $links
   *   The links array.
   * @param string $type
   *   The language type.
   * @param \Drupal\Core\Url $path
   *   The request path.
   */
  public function __construct(array &$links, string $type, Url $path) {
    $this->links =& $links;
    $this->type = $type;
    $this->path = $path;
  }

  /**
   * Get the links array.
   *
   * @return array
   *   The links array.
   */
  public function &getLinks() : array {
    return $this->links;
  }

  /**
   * Set the link for a specific language code.
   *
   * @param string $langcode
   *   The link language code.
   * @param array $link
   *   The link path.
   */
  public function setLinkForLanguage($langcode, array $link) {
    $this->links[$langcode] = $link;
  }

  /**
   * Get the language type.
   *
   * @return string
   *   The language type.
   */
  public function getType() : string {
    return $this->type;
  }

  /**
   * Get the request path.
   *
   * @return \Drupal\Core\Url
   *   The link path.
   */
  public function getPath() : Url {
    return $this->path;
  }

  /**
   * {@inheritdoc}
   */
  public function getDispatcherType() : string {
    return HookEventDispatcherInterface::LANGUAGE_SWITCH_LINKS_ALTER;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LanguageSwitchLinksAlterEvent::$links private property The links array.
LanguageSwitchLinksAlterEvent::$path private property The request path.
LanguageSwitchLinksAlterEvent::$type private property The language type.
LanguageSwitchLinksAlterEvent::getDispatcherType public function Get the dispatcher type. Overrides EventInterface::getDispatcherType
LanguageSwitchLinksAlterEvent::getLinks public function Get the links array.
LanguageSwitchLinksAlterEvent::getPath public function Get the request path.
LanguageSwitchLinksAlterEvent::getType public function Get the language type.
LanguageSwitchLinksAlterEvent::setLinkForLanguage public function Set the link for a specific language code.
LanguageSwitchLinksAlterEvent::__construct public function LanguageSwitchLinksAlterEvent constructor.