AbstractProvider.php in Synonyms 8
File
src/Plugin/Synonyms/Provider/AbstractProvider.php
View source
<?php
namespace Drupal\synonyms\Plugin\Synonyms\Provider;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\synonyms\SynonymsProviderInterface\SynonymsProviderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class AbstractProvider extends PluginBase implements SynonymsProviderInterface, ContainerFactoryPluginInterface {
use StringTranslationTrait;
protected $container;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ContainerInterface $container) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->container = $container;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container);
}
public function getBehaviorService() {
return $this
->getPluginDefinition()['synonyms_behavior_service'];
}
public function getBehaviorServiceInstance() {
return $this->container
->get($this
->getPluginDefinition()['synonyms_behavior_service']);
}
}