LinkExtractorBase.php in Link checker 8
File
src/Plugin/LinkExtractorBase.php
View source
<?php
namespace Drupal\linkchecker\Plugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class LinkExtractorBase extends PluginBase implements LinkExtractorInterface, ContainerFactoryPluginInterface {
protected $linkcheckerSetting;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ImmutableConfig $config) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->linkcheckerSetting = $config;
}
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'));
}
protected abstract function extractUrlFromField(array $value);
public function extract(array $value) {
$urls = [];
foreach ($value as $item) {
$urls = array_merge($urls, $this
->extractUrlFromField($item));
}
return $urls;
}
}