AdministrationLanguageNegotiationConditionManager.php in Administration Language Negotiation 8
File
src/AdministrationLanguageNegotiationConditionManager.php
View source
<?php
declare (strict_types=1);
namespace Drupal\administration_language_negotiation;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Executable\ExecutableInterface;
use Drupal\Core\Executable\ExecutableManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
class AdministrationLanguageNegotiationConditionManager extends DefaultPluginManager implements ExecutableManagerInterface {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/AdministrationLanguageNegotiationCondition', $namespaces, $module_handler, 'Drupal\\administration_language_negotiation\\AdministrationLanguageNegotiationConditionInterface', 'Drupal\\administration_language_negotiation\\Annotation\\AdministrationLanguageNegotiationCondition');
$this->cacheBackend = $cache_backend;
$this->cacheKeyPrefix = 'administration_language_negotiation_condition_plugins';
$this->cacheKey = 'administration_language_negotiation_condition_plugins';
$this
->alterInfo('administration_language_negotiation_condition_info');
}
public function createInstance($plugin_id, array $configuration = []) {
$plugin = $this
->getFactory()
->createInstance($plugin_id, $configuration);
if (!empty($configuration['context'])) {
foreach ($configuration['context'] as $name => $context) {
$plugin
->setContextValue($name, $context);
}
}
return $plugin
->setExecutableManager($this);
}
public function execute(ExecutableInterface $condition) {
return $condition
->evaluate();
}
public function getDefinitions() {
$definitions = parent::getDefinitions();
uasort($definitions, 'Drupal\\Component\\Utility\\SortArray::sortByWeightElement');
return $definitions;
}
}