You are here

class Canonical in Linkit 8.5

A substitution plugin for the canonical URL of an entity.

Plugin annotation


@Substitution(
  id = "canonical",
  label = @Translation("Canonical URL"),
)

Hierarchy

Expanded class hierarchy of Canonical

1 file declares its use of Canonical
SubstitutionPluginTest.php in tests/src/Kernel/SubstitutionPluginTest.php

File

src/Plugin/Linkit/Substitution/Canonical.php, line 18

Namespace

Drupal\linkit\Plugin\Linkit\Substitution
View source
class Canonical extends PluginBase implements SubstitutionInterface {

  /**
   * {@inheritdoc}
   */
  public function getUrl(EntityInterface $entity) {
    return $entity
      ->toUrl('canonical')
      ->toString(TRUE);
  }

  /**
   * {@inheritdoc}
   */
  public static function isApplicable(EntityTypeInterface $entity_type) {
    return $entity_type
      ->hasLinkTemplate('canonical');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Canonical::getUrl public function Get the URL associated with a given entity. Overrides SubstitutionInterface::getUrl
Canonical::isApplicable public static function Checks if this substitution plugin is applicable for the given entity type. Overrides SubstitutionInterface::isApplicable
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92