diff --git a/core/modules/overlay/lib/Drupal/overlay/Controller/OverlayController.php b/core/modules/overlay/lib/Drupal/overlay/Controller/OverlayController.php index 08c76bb..cdb14e4 100644 --- a/core/modules/overlay/lib/Drupal/overlay/Controller/OverlayController.php +++ b/core/modules/overlay/lib/Drupal/overlay/Controller/OverlayController.php @@ -7,16 +7,50 @@ namespace Drupal\overlay\Controller; +use Drupal\Core\Controller\ControllerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; /** * Controller routines for overlay routes. + * + * @todo keeping the controllerInterface since we should be injecting + * something to take care of the overlay_render_region() call. */ -class OverlayController { +class OverlayController implements ControllerInterface { /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static(); + } + + /** + * Constructs a OverlayController object. + */ + public function __construct() { + } + + /** + * Prints the markup obtained by rendering a single region of the page. + * + * @todo add a DI for managing the overlay_render_region() call. + * + * @param string + * The name of the page region to render. + * + * @return \Symfony\Component\HttpFoundation\Response + * + * @see Drupal.overlay.refreshRegions() + */ + public function regionRender($region) { + return new Response(overlay_render_region($region)); + } + /** * Dismisses the overlay accessibility message for this user. * * @param \Symfony\Component\HttpFoundation\Request $request @@ -40,5 +74,4 @@ public function overlayMessage(Request $request) { // Destination is normally given. Go to the user profile as a fallback. return new RedirectResponse(url('user/' . $account->id() . '/edit', array('absolute' => TRUE))); } - } diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module index 52edcf8..2c8ebf2 100644 --- a/core/modules/overlay/overlay.module +++ b/core/modules/overlay/overlay.module @@ -25,20 +25,6 @@ function overlay_help($path, $arg) { } /** - * Implements hook_menu() - */ -function overlay_menu() { - $items['overlay-ajax/%'] = array( - 'title' => '', - 'page callback' => 'overlay_ajax_render_region', - 'page arguments' => array(1), - 'access arguments' => array('access overlay'), - 'type' => MENU_CALLBACK, - ); - return $items; -} - -/** * Implements hook_admin_paths(). */ function overlay_admin_paths() { @@ -843,17 +829,3 @@ function overlay_trigger_refresh() { unset($_SESSION['overlay_refresh_parent']); } } - -/** - * Prints the markup obtained by rendering a single region of the page. - * - * This function is intended to be called via Ajax. - * - * @param $region - * The name of the page region to render. - * - * @see Drupal.overlay.refreshRegions() - */ -function overlay_ajax_render_region($region) { - return new Response(overlay_render_region($region)); -} diff --git a/core/modules/overlay/overlay.routing.yml b/core/modules/overlay/overlay.routing.yml index 9f22f56..50bc120 100644 --- a/core/modules/overlay/overlay.routing.yml +++ b/core/modules/overlay/overlay.routing.yml @@ -5,3 +5,9 @@ overlay_message: requirements: _access_overlay_dismiss_message: 'TRUE' +overlay_ajax: + pattern: '/overlay-ajax/{region}' + defaults: + _controller: '\Drupal\overlay\Controller\OverlayController::regionRender' + requirements: + _permission: 'access overlay'