FrontendEnvironmentPluginCollection.php in Build Hooks 8.2
File
src/FrontendEnvironmentPluginCollection.php
View source
<?php
namespace Drupal\build_hooks;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\Plugin\DefaultSingleLazyPluginCollection;
class FrontendEnvironmentPluginCollection extends DefaultSingleLazyPluginCollection {
protected $frontendEnvironmentId;
public function __construct(PluginManagerInterface $manager, $instance_id, array $configuration, $frontend_environment_id) {
parent::__construct($manager, $instance_id, $configuration);
$this->frontendEnvironmentId = $frontend_environment_id;
}
protected function initializePlugin($instance_id) {
if (!$instance_id) {
throw new PluginException("The frontend environment '{$this->frontendEnvironmentId}' did not specify a plugin.");
}
try {
parent::initializePlugin($instance_id);
} catch (PluginException $e) {
$module = $this->configuration['provider'];
if (!$module || \Drupal::moduleHandler()
->moduleExists($module)) {
throw $e;
}
}
}
}