diff --git a/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php index ac48bc8..1cec8c2 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php @@ -19,9 +19,36 @@ /** * Main subscriber for VIEW HTTP responses. * - * @todo This needs to get refactored to be extensible so that we can handle - * more than just Html and Drupal-specific JSON requests. See - * http://drupal.org/node/1594870 + * Although it appears as though this class only handles a fixed list of + * content-types, it should be noted that this subscriber is only required when + * a controller does not return a Response object. If you have a requirement to + * handler another content-type the recommended approach is to + * 1) Implement a service tagged with event_subscriber that implements + * \Symfony\Component\EventDispatcher\EventSubscriberInterface and reacts to + * \Symfony\Component\HttpKernel\KernelEvents::REQUEST and use that to register + * your content type. See \Drupal\Core\Ajax\AjaxSubscriber for an example. + * 2) Create a service that implements + * \Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface and is + * tagged as a 'route_enhancer'. If your service needs to react to legacy + * (hook_menu() page callbacks) it should also be tagged as + * 'legacy_route_enhancer'. In your service, use the + * RouterEnhancerInterface::enhance() method to examine the incoming request + * and routing defaults and nominate an appropriate controller. See + * \Drupal\Core\Routing\Enhancer\AjaxEnhancer for an example. + * 3) Return an instance or sub-class of + * \Symfony\Component\HttpFoundation\Response from your controller. See + * \Drupal\Core\AjaxController for an example. + * + * With this approach, this class is not required. + * + * @see \Drupal\Core\Ajax\AjaxSubscriber::onKernelRequest() + * @see \Drupal\Core\Routing\Enhancer\AjaxEnhancer::enhance() + * @see \Drupal\Core\AjaxController::content() + * @see \Symfony\Component\HttpFoundation\Response + * @see \Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface + * @see hook_menu() + * @see \Symfony\Component\HttpKernel\KernelEvents::REQUEST + * @see Symfony\Component\EventDispatcher\EventSubscriberInterface */ class ViewSubscriber implements EventSubscriberInterface {