BackendManager.php in Advanced Queue 8
File
src/BackendManager.php
View source
<?php
namespace Drupal\advancedqueue;
use Drupal\advancedqueue\Annotation\AdvancedQueueBackend;
use Drupal\advancedqueue\Plugin\AdvancedQueue\Backend\BackendInterface;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
class BackendManager extends DefaultPluginManager {
protected $defaults = [
'id' => '',
'label' => '',
];
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/AdvancedQueue/Backend', $namespaces, $module_handler, BackendInterface::class, AdvancedQueueBackend::class);
$this
->alterInfo('advancedqueue_backend_info');
$this
->setCacheBackend($cache_backend, 'advancedqueue_backend_plugins');
}
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
foreach ([
'id',
'label',
] as $required_property) {
if (empty($definition[$required_property])) {
throw new PluginException(sprintf('The backend "%s" must define the "%s" property.', $plugin_id, $required_property));
}
}
}
}