IconSetBase.php in Icon API 8
File
src/Plugin/Icon/IconSetBase.php
View source
<?php
namespace Drupal\icon\Plugin\Icon;
use Drupal\Core\Plugin\PluginBase;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class IconSetBase extends PluginBase implements IconSetInterface {
use ContainerAwareTrait;
private $icons = [];
public function __construct(array $configuration, $plugin_id, $plugin_definition, ContainerInterface $container = NULL, $icons = []) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
if (!isset($container)) {
$container = \Drupal::getContainer();
}
$this
->setContainer($container);
$this->icons = $icons;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container);
}
public function getLabel() {
return isset($this->pluginDefinition['label']) ? $this->pluginDefinition['label'] : $this
->getPluginId();
}
public function getIcons() {
return isset($this->pluginDefinition['icons']) ? $this->pluginDefinition['icons'] : $this->icons;
}
public function getProvider() {
return isset($this->pluginDefinition['provider']) ? $this->pluginDefinition['provider'] : '';
}
public function getUrl() {
return isset($this->pluginDefinition['url']) ? $this->pluginDefinition['url'] : '';
}
public function getVersion() {
return isset($this->pluginDefinition['version']) ? $this->pluginDefinition['version'] : '';
}
public function getPath() {
return isset($this->pluginDefinition['path']) ? $this->pluginDefinition['path'] : '';
}
public function getRenderer() {
return isset($this->pluginDefinition['renderer']) ? $this->pluginDefinition['renderer'] : '';
}
public function getSettings() {
return isset($this->pluginDefinition['settings']) ? $this->pluginDefinition['settings'] : [];
}
public function getAttached() {
return isset($this->pluginDefinition['attached']) ? $this->pluginDefinition['attached'] : [];
}
public function process() {
}
public function getIcon($key = 'icon') {
if (isset($this->icons[$key])) {
return $this->icons[$key];
}
return FALSE;
}
public function setIcon($value, $key = 'icon') {
$this->icons[$key] = $value;
}
}