EventSubscriber.php in Zircon Profile 8
File
core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php
View source
<?php
namespace Drupal\config_collection_install_test;
use Drupal\Core\Config\ConfigCollectionInfo;
use Drupal\Core\Config\ConfigEvents;
use Drupal\Core\State\StateInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class EventSubscriber implements EventSubscriberInterface {
protected $state;
public function __construct(StateInterface $state) {
$this->state = $state;
}
public function addCollections(ConfigCollectionInfo $collection_info) {
$collections = $this->state
->get('config_collection_install_test.collection_names', array());
foreach ($collections as $collection) {
$collection_info
->addCollection($collection);
}
}
static function getSubscribedEvents() {
$events[ConfigEvents::COLLECTION_INFO][] = array(
'addCollections',
);
return $events;
}
}