5 * Definition of Drupal\Core\EventSubscriber\DrunkControllerSubscriber.
8 namespace Drupal\Core\EventSubscriber
;
10 use Symfony\Component\HttpKernel\KernelEvents
;
11 use Symfony\Component\HttpKernel\Event\FilterControllerEvent
;
12 use Symfony\Component\EventDispatcher\EventSubscriberInterface
;
14 use Drupal\Core\Config\Entity\Display
;
17 * Controller injector for text/html responses.
19 class DrunkControllerSubscriber implements EventSubscriberInterface
{
22 * Attaches a controller for blocks-driven HTML rendering, if appropriate.
24 * This determines if the Request and Route are appropriate candidates for
25 * passing through block-driven rendering, and if so, attaches a controller
28 * This is more or less the default case; we only don't take over if Drupal
29 * is doing things like form processing, returning JSON or other things that
30 * (generally) do not involve composing HTML.
33 public
function onDrunkenKernelController(FilterControllerEvent
$event) {
34 $request = $event->getRequest();
35 // @todo implement a separate flag and remove this hardmapping
36 if ('\Drupal\Core\Booze\DrunkController::respond' !== $request->attributes
->get('_controller')) {
40 $route = $request->attributes
->get('_route');
43 $display = entity_load('booze_display', $route);
46 if (empty($display)) {
47 // @todo put a real, meaningful exception here. and/or figure out fallback behavior.
48 // throw new \Exception('no display');
49 // $display = new Display(array('id' => 'new'));
53 $display->setMainContent($request->attributes
->get('_content'));
55 $request->attributes
->set('_display', $display);
59 * Registers the methods in this class that should be listeners.
62 * An array of event listener definitions.
64 public static
function getSubscribedEvents() {
65 $events[KernelEvents
::CONTROLLER
][] = array('onDrunkenKernelController', 100);