You are here

public function InstallablePluginTrait::getUrl in Markdown 8.2

Retrieves the definition's URL property as an object.

Parameters

array $options: An array of options to pass to the Url object constructor.

Return value

\Drupal\Core\Url|void A Url object or NULL if no URL is set.

2 calls to InstallablePluginTrait::getUrl()
InstallablePluginTrait::getLink in src/Annotation/InstallablePluginTrait.php
Retrieves the plugin as a link using its label and URL.
PeclExtension::getUrl in src/Annotation/PeclExtension.php
Retrieves the definition's URL property as an object.
1 method overrides InstallablePluginTrait::getUrl()
PeclExtension::getUrl in src/Annotation/PeclExtension.php
Retrieves the definition's URL property as an object.

File

src/Annotation/InstallablePluginTrait.php, line 180

Class

InstallablePluginTrait
Trait for adding installable plugin properties to annotations.

Namespace

Drupal\markdown\Annotation

Code

public function getUrl(array $options = []) {
  if ($url = $this->url) {
    if (UrlHelper::isExternal($url)) {
      if (!isset($options['attributes']['target'])) {
        $options['attributes']['target'] = '_blank';
      }
      return Url::fromUri($url, $options);
    }
    return Url::fromUserInput($url, $options);
  }
}