Sets the overlay mode and adds proper JavaScript and styles to the page.
Note that since setting the overlay mode triggers a variety of behaviors (including hooks being invoked), it can only be done once per page request. Therefore, the first call to this function which passes along a value of the $mode parameter controls the overlay mode that will be used.
$mode: To set the mode, pass in one of the following values:
This parameter is optional, and if omitted, the current mode will be returned with no action taken.
The current mode, if any has been set, or NULL if no mode has been set.
\Drupal\overlay\EventSubscriber\OverlaySubscriber::onRequest()
function overlay_set_mode($mode = NULL) {
global $base_path;
$overlay_mode =& drupal_static(__FUNCTION__);
// Make sure external resources are not included more than once. Also return
// the current mode, if no mode was specified.
if (isset($overlay_mode) || !isset($mode)) {
return $overlay_mode;
}
$overlay_mode = $mode;
switch ($overlay_mode) {
case 'parent':
drupal_add_library('overlay', 'drupal.overlay.parent');
// Allow modules to act upon overlay events.
module_invoke_all('overlay_parent_initialize');
break;
case 'child':
drupal_add_library('overlay', 'drupal.overlay.child');
// Allow modules to act upon overlay events.
module_invoke_all('overlay_child_initialize');
break;
}
return $overlay_mode;
}