You are here

abstract class LinkExtractorBase in Link checker 8

Base class for Link extractor plugins.

Hierarchy

Expanded class hierarchy of LinkExtractorBase

2 files declare their use of LinkExtractorBase
HtmlLinkExtractor.php in src/Plugin/LinkExtractor/HtmlLinkExtractor.php
LinkLinkExtractor.php in src/Plugin/LinkExtractor/LinkLinkExtractor.php

File

src/Plugin/LinkExtractorBase.php, line 13

Namespace

Drupal\linkchecker\Plugin
View source
abstract class LinkExtractorBase extends PluginBase implements LinkExtractorInterface, ContainerFactoryPluginInterface {

  /**
   * The Linkchecker settings.
   *
   * @var \Drupal\Core\Config\ImmutableConfig
   */
  protected $linkcheckerSetting;

  /**
   * LinkExtractorBase plugin constructor.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, ImmutableConfig $config) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->linkcheckerSetting = $config;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('config.factory')
      ->get('linkchecker.settings'));
  }

  /**
   * Extracts a URLs from field.
   *
   * @return array
   *   Array of URLs.
   */
  protected abstract function extractUrlFromField(array $value);

  /**
   * {@inheritdoc}
   */
  public function extract(array $value) {
    $urls = [];
    foreach ($value as $item) {
      $urls = array_merge($urls, $this
        ->extractUrlFromField($item));
    }
    return $urls;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LinkExtractorBase::$linkcheckerSetting protected property The Linkchecker settings.
LinkExtractorBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
LinkExtractorBase::extract public function Extracts links from field list. Overrides LinkExtractorInterface::extract
LinkExtractorBase::extractUrlFromField abstract protected function Extracts a URLs from field. 2
LinkExtractorBase::__construct public function LinkExtractorBase plugin constructor. Overrides PluginBase::__construct
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.