StockEventsManager.php in Commerce Stock 8
File
src/StockEventsManager.php
View source
<?php
namespace Drupal\commerce_stock;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
class StockEventsManager extends DefaultPluginManager implements StockEventsManagerInterface {
protected $defaults = [
'id' => '',
'label' => '',
];
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/StockEvents', $namespaces, $module_handler, 'Drupal\\commerce_stock\\Plugin\\StockEventsInterface', 'Drupal\\commerce_stock\\Annotation\\StockEvents');
$this
->alterInfo('commerce_stock_stock_events_info');
$this->moduleHandler = $module_handler;
$this
->setCacheBackend($cache_backend, 'commerce_stock_stock_events');
}
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
if (empty($definition['id'])) {
throw new PluginException(sprintf('plugin property (%s) definition "is" is required.', $plugin_id));
}
}
}