RestConfigSubscriber.php in Drupal 8
File
core/modules/rest/src/EventSubscriber/RestConfigSubscriber.php
View source
<?php
namespace Drupal\rest\EventSubscriber;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Drupal\Core\Routing\RouteBuilderInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class RestConfigSubscriber implements EventSubscriberInterface {
protected $routerBuilder;
public function __construct(RouteBuilderInterface $router_builder) {
$this->routerBuilder = $router_builder;
}
public function onSave(ConfigCrudEvent $event) {
$saved_config = $event
->getConfig();
if ($saved_config
->getName() === 'rest.settings' && $event
->isChanged('bc_entity_resource_permissions')) {
$this->routerBuilder
->setRebuildNeeded();
}
}
public static function getSubscribedEvents() {
$events[ConfigEvents::SAVE][] = [
'onSave',
];
return $events;
}
}