ScssCompilerPluginManager.php in SCSS/Less Compiler 8
File
src/ScssCompilerPluginManager.php
View source
<?php
namespace Drupal\scss_compiler;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
class ScssCompilerPluginManager extends DefaultPluginManager {
protected $compilers;
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/ScssCompiler', $namespaces, $module_handler, '\\Drupal\\scss_compiler\\ScssCompilerPluginInterface', '\\Drupal\\scss_compiler\\Annotation\\ScssCompilerPlugin');
$this
->alterInfo('scss_compiler_info');
$this
->setCacheBackend($cache_backend, 'scss_compiler_info_plugins');
}
public function getInstanceById($id) {
if (isset($this->compilers[$id])) {
return $this->compilers[$id];
}
try {
$definitions = $this
->getDefinitions();
$this->compilers[$id] = FALSE;
if (isset($definitions[$id])) {
$this->compilers[$id] = $this
->createInstance($id);
}
return $this->compilers[$id];
} catch (\Exception $e) {
\Drupal::messenger()
->addError($e
->getMessage());
}
}
}