Commit f37f7a1e authored by alexpott's avatar alexpott

Issue #1978932 by laurentchardin, kbentham: Convert overlay_ajax_render_region() to a Controller.

parent 5fc01a83
......@@ -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)));
}
}
......@@ -24,20 +24,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().
*/
......@@ -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));
}
......@@ -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'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment