LogTypeManager.php in farmOS 2.x
File
modules/core/entity/src/LogTypeManager.php
View source
<?php
namespace Drupal\farm_entity;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
class LogTypeManager extends DefaultPluginManager {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/Log/LogType', $namespaces, $module_handler, 'Drupal\\farm_entity\\Plugin\\Log\\LogType\\LogTypeInterface', 'Drupal\\farm_entity\\Annotation\\LogType');
$this
->alterInfo('log_type_info');
$this
->setCacheBackend($cache_backend, 'log_type_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 log type %s must define the %s property.', $plugin_id, $required_property));
}
}
}
}