diff --git a/core/core.services.yml b/core/core.services.yml index 402d6ee..c814824 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -410,13 +410,15 @@ services: arguments: ['@controller_resolver', '@string_translation', '@title_resolver'] controller.ajax: class: Drupal\Core\Controller\AjaxController - arguments: ['@controller_resolver'] + arguments: ['@controller_resolver', '@ajax_response_renderer'] controller.entityform: class: Drupal\Core\Entity\HtmlEntityFormController arguments: ['@controller_resolver', '@service_container', '@entity.manager'] controller.dialog: class: Drupal\Core\Controller\DialogController arguments: ['@controller_resolver', '@title_resolver'] + ajax_response_renderer: + class: Drupal\Core\Ajax\AjaxResponseRenderer router_listener: class: Symfony\Component\HttpKernel\EventListener\RouterListener tags: @@ -428,7 +430,7 @@ services: class: Drupal\Core\EventSubscriber\ViewSubscriber tags: - { name: event_subscriber } - arguments: ['@content_negotiation', '@title_resolver'] + arguments: ['@content_negotiation', '@title_resolver', '@ajax_response_renderer'] html_view_subscriber: class: Drupal\Core\EventSubscriber\HtmlViewSubscriber tags: diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index de6f5d0..b2f175a 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -5,8 +5,6 @@ * Functions for use with Drupal's Ajax framework. */ -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; - /** * @defgroup ajax Ajax framework * @{ @@ -50,7 +48,8 @@ * #ajax['callback'], which returns the form element that has been updated * and needs to be returned to the browser, or alternatively, an array of * custom Ajax commands. - * - The array is serialized using ajax_render() and sent to the browser. + * - The array is serialized using + * \Drupal\Core\Ajax\AjaxResponse::ajaxRender() and sent to the browser. * - The browser unserializes the returned JSON string into an array of * command objects and executes each command, resulting in the old page * content within and including the HTML element specified by @@ -125,11 +124,12 @@ * executed by the calling code. * - #ajax['path']: The menu path to use for the request. This is often omitted * and the default is used. This path should map - * to a menu page callback that returns data using ajax_render(). Defaults to - * 'system/ajax', which invokes \Drupal\system\FormAjaxController::content(), - * eventually calling the function named in #ajax['callback']. If you use a - * custom path, you must set up the menu entry and handle the entire callback - * in your own code. + * to a controller that returns data using + * \Drupal\Core\Ajax\AjaxResponse::ajaxRender(). Defaults to 'system/ajax', + * which invokes \Drupal\system\FormAjaxController::content(), eventually + * calling the function named in #ajax['callback']. If you use a custom path, + * you must set up the menu entry and handle the entire callback in your own + * code. * - #ajax['wrapper']: The CSS ID of the area to be replaced by the content * returned by the #ajax['callback'] function. The content returned from * the callback will replace the entire element named by #ajax['wrapper']. @@ -185,9 +185,10 @@ * '/ajax/' so that the submit handler can tell if the form was submitted * in a degraded state or not. * - * When responding to Ajax requests, the server should do what it needs to do - * for that request, then create a commands array. This commands array will - * be converted to a JSON object and returned to the client, which will then + * As developer you basically create a \Drupal\Core\Ajax\AjaxResponse and add + * a couple of \Drupal\Core\Ajax\CommandInterface onto it, which will be + * converted to a commands array automatically. This commands array will be + * converted to a JSON object and returned to the client, which will then * iterate over the array and process it like a macro language. * * Each command item is an associative array which will be converted to a @@ -196,177 +197,30 @@ * Drupal.ajax[command] space. The command array may contain any other data that * the command needs to process, e.g. 'method', 'selector', 'settings', etc. * - * Commands are usually created with a couple of helper functions, so they - * look like this: * @code - * $commands = array(); + * $ajax_response = new \Drupal\Core\Ajax\AjaxResponse(); * // Replace the content of '#object-1' on the page with 'some html here'. - * $commands[] = ajax_command_replace('#object-1', 'some html here'); + * $ajax_response->addCommand(new ReplaceCommand('#object-1', 'some html here'); * // Add a visual "changed" marker to the '#object-1' element. - * $commands[] = ajax_command_changed('#object-1'); - * // #ajax['callback'] functions are supposed to return render arrays. If - * // returning an Ajax commands array, it must be encapsulated in a render - * // array structure. - * return array('#type' => 'ajax', '#commands' => $commands); + * $ajax_response->addCommand(new ChangedCommand('#object-1'); + * return $ajax_response; * @endcode * - * When returning an Ajax command array, it is often useful to have - * status messages rendered along with other tasks in the command array. - * In that case the the Ajax commands array may be constructed like this: + * When returning an Ajax response, it is often useful to have status messages + * rendered along with other tasks. In that case the Ajax response may be + * constructed like this: * @code - * $commands = array(); - * $commands[] = ajax_command_replace(NULL, $output); - * $commands[] = ajax_command_prepend(NULL, theme('status_messages')); - * return array('#type' => 'ajax', '#commands' => $commands); + * $ajax_response = new \Drupal\Core\Ajax\AjaxResponse(); + * $ajax_response->addCommand(new ReplaceCommand(NULL, $output)); + * $ajax_response->addCommand(new PrependCommand(NULL, theme('status_messages')); + * return $ajax_response; * @endcode * * See @link ajax_commands Ajax framework commands @endlink - */ - -/** - * Renders a commands array into JSON. * - * @param $commands - * A list of macro commands generated by the use of ajax_command_*() - * functions. + * @see \Drupal\Core\Ajax\AjaxResponse + * @see \Drupal\Core\Ajax\CommandInterface */ -function ajax_render($commands = array()) { - // Ajax responses aren't rendered with html.html.twig, so we have to call - // drupal_get_css() and drupal_get_js() here, in order to have new files added - // during this request to be loaded by the page. We only want to send back - // files that the page hasn't already loaded, so we implement simple diffing - // logic using array_diff_key(). - foreach (array('css', 'js') as $type) { - // It is highly suspicious if $_POST['ajax_page_state'][$type] is empty, - // since the base page ought to have at least one JS file and one CSS file - // loaded. It probably indicates an error, and rather than making the page - // reload all of the files, instead we return no new files. - if (!\Drupal::request()->request->get("ajax_page_state[$type]", NULL, TRUE)) { - $items[$type] = array(); - } - else { - $function = '_drupal_add_' . $type; - $items[$type] = $function(); - drupal_alter($type, $items[$type]); - // @todo Inline CSS and JS items are indexed numerically. These can't be - // reliably diffed with array_diff_key(), since the number can change - // due to factors unrelated to the inline content, so for now, we strip - // the inline items from Ajax responses, and can add support for them - // when _drupal_add_css() and _drupal_add_js() are changed to use a hash - // of the inline content as the array key. - foreach ($items[$type] as $key => $item) { - if (is_numeric($key)) { - unset($items[$type][$key]); - } - } - // Ensure that the page doesn't reload what it already has. - $items[$type] = array_diff_key($items[$type], $_POST['ajax_page_state'][$type]); - } - } - - // Render the HTML to load these files, and add AJAX commands to insert this - // HTML in the page. We pass TRUE as the $skip_alter argument to prevent the - // data from being altered again, as we already altered it above. Settings are - // handled separately, afterwards. - if (isset($items['js']['settings'])) { - unset($items['js']['settings']); - } - $styles = drupal_get_css($items['css'], TRUE); - $scripts_footer = drupal_get_js('footer', $items['js'], TRUE); - $scripts_header = drupal_get_js('header', $items['js'], TRUE); - - $extra_commands = array(); - if (!empty($styles)) { - $extra_commands[] = ajax_command_add_css($styles); - } - if (!empty($scripts_header)) { - $extra_commands[] = ajax_command_prepend('head', $scripts_header); - } - if (!empty($scripts_footer)) { - $extra_commands[] = ajax_command_append('body', $scripts_footer); - } - if (!empty($extra_commands)) { - $commands = array_merge($extra_commands, $commands); - } - - // Now add a command to merge changes and additions to drupalSettings. - $scripts = _drupal_add_js(); - if (!empty($scripts['settings'])) { - $settings = drupal_merge_js_settings($scripts['settings']['data']); - array_unshift($commands, ajax_command_settings($settings, TRUE)); - } - - // Allow modules to alter any Ajax response. - drupal_alter('ajax_render', $commands); - - return drupal_json_encode($commands); -} - -/** - * Converts the return value of a page callback into an Ajax commands array. - * - * @param $page_callback_result - * The result of a page callback. Can be one of: - * - NULL: to indicate no content. - * - An integer menu status constant: to indicate an error condition. - * - A string of HTML content. - * - A renderable array of content. - * - * @return - * An Ajax commands array that can be passed to ajax_render(). - */ -function ajax_prepare_response($page_callback_result) { - $commands = array(); - if (!isset($page_callback_result)) { - // Simply delivering an empty commands array is sufficient. This results - // in the Ajax request being completed, but nothing being done to the page. - } - elseif (is_int($page_callback_result)) { - switch ($page_callback_result) { - case MENU_NOT_FOUND: - $commands[] = ajax_command_alert(t('The requested page could not be found.')); - break; - - case MENU_ACCESS_DENIED: - $commands[] = ajax_command_alert(t('You are not authorized to access this page.')); - break; - - case MENU_SITE_OFFLINE: - $commands[] = ajax_command_alert(filter_xss_admin(t(\Drupal::config('system.maintenance')->get('message'), array('@site' => \Drupal::config('system.site')->get('name'))))); - break; - } - } - elseif (is_array($page_callback_result) && isset($page_callback_result['#type']) && ($page_callback_result['#type'] == 'ajax')) { - // Complex Ajax callbacks can return a result that contains an error message - // or a specific set of commands to send to the browser. - $page_callback_result += element_info('ajax'); - $error = $page_callback_result['#error']; - if (isset($error) && $error !== FALSE) { - if ((empty($error) || $error === TRUE)) { - $error = t('An error occurred while handling the request: The server received invalid input.'); - } - $commands[] = ajax_command_alert($error); - } - else { - $commands = $page_callback_result['#commands']; - } - } - else { - // Like normal page callbacks, simple Ajax callbacks can return HTML - // content, as a string or render array. This HTML is inserted in some - // relationship to #ajax['wrapper'], as determined by which jQuery DOM - // manipulation method is used. The method used is specified by - // #ajax['method']. The default method is 'replaceWith', which completely - // replaces the old wrapper element and its content with the new HTML. - $html = is_string($page_callback_result) ? $page_callback_result : drupal_render($page_callback_result); - $commands[] = ajax_command_insert(NULL, $html); - // Add the status messages inside the new content's wrapper element, so that - // on subsequent Ajax requests, it is treated as old content. - $commands[] = ajax_command_prepend(NULL, theme('status_messages')); - } - - return $commands; -} /** * Form element processing handler for the #ajax form property. @@ -558,266 +412,3 @@ function ajax_pre_render_element($element) { /** * @} End of "defgroup ajax". */ - -/** - * @defgroup ajax_commands Ajax framework commands - * @{ - * Functions to create various Ajax commands. - * - * These functions can be used to create arrays for use with the - * ajax_render() function. - */ - -/** - * Creates a Drupal Ajax 'alert' command. - * - * The 'alert' command instructs the client to display a JavaScript alert - * dialog box. - * - * This command is implemented by Drupal.AjaxCommands.prototype.alert() - * defined in misc/ajax.js. - * - * @param $text - * The message string to display to the user. - * - * @return - * An array suitable for use with the ajax_render() function. - */ -function ajax_command_alert($text) { - return array( - 'command' => 'alert', - 'text' => $text, - ); -} - -/** - * Creates a Drupal Ajax 'insert' command using the method in #ajax['method']. - * - * This command instructs the client to insert the given HTML using whichever - * jQuery DOM manipulation method has been specified in the #ajax['method'] - * variable of the element that triggered the request. - * - * This command is implemented by Drupal.AjaxCommands.prototype.insert() - * defined in misc/ajax.js. - * - * @param $selector - * A jQuery selector string. If the command is a response to a request from - * an #ajax form element then this value can be NULL. - * @param $html - * The data to use with the jQuery method. - * @param $settings - * An optional array of settings that will be used for this command only. - * - * @return - * An array suitable for use with the ajax_render() function. - */ -function ajax_command_insert($selector, $html, $settings = NULL) { - return array( - 'command' => 'insert', - 'method' => NULL, - 'selector' => $selector, - 'data' => $html, - 'settings' => $settings, - ); -} - -/** - * Creates a Drupal Ajax 'insert/prepend' command. - * - * The 'insert/prepend' command instructs the client to use jQuery's prepend() - * method to prepend the given HTML content to the inside each element matched - * by the given selector. - * - * This command is implemented by Drupal.AjaxCommands.prototype.insert() - * defined in misc/ajax.js. - * - * @param $selector - * A jQuery selector string. If the command is a response to a request from - * an #ajax form element then this value can be NULL. - * @param $html - * The data to use with the jQuery prepend() method. - * @param $settings - * An optional array of settings that will be used for this command only. - * - * @return - * An array suitable for use with the ajax_render() function. - * - * @see http://docs.jquery.com/Manipulation/prepend#content - */ -function ajax_command_prepend($selector, $html, $settings = NULL) { - return array( - 'command' => 'insert', - 'method' => 'prepend', - 'selector' => $selector, - 'data' => $html, - 'settings' => $settings, - ); -} - -/** - * Creates a Drupal Ajax 'insert/append' command. - * - * The 'insert/append' command instructs the client to use jQuery's append() - * method to append the given HTML content to the inside of each element matched - * by the given selector. - * - * This command is implemented by Drupal.AjaxCommands.prototype.insert() - * defined in misc/ajax.js. - * - * @param $selector - * A jQuery selector string. If the command is a response to a request from - * an #ajax form element then this value can be NULL. - * @param $html - * The data to use with the jQuery append() method. - * @param $settings - * An optional array of settings that will be used for this command only. - * - * @return - * An array suitable for use with the ajax_render() function. - * - * @see http://docs.jquery.com/Manipulation/append#content - */ -function ajax_command_append($selector, $html, $settings = NULL) { - return array( - 'command' => 'insert', - 'method' => 'append', - 'selector' => $selector, - 'data' => $html, - 'settings' => $settings, - ); -} - -/** - * Creates a Drupal Ajax 'remove' command. - * - * The 'remove' command instructs the client to use jQuery's remove() method - * to remove each of elements matched by the given selector, and everything - * within them. - * - * This command is implemented by Drupal.AjaxCommands.prototype.remove() - * defined in misc/ajax.js. - * - * @param $selector - * A jQuery selector string. If the command is a response to a request from - * an #ajax form element then this value can be NULL. - * - * @return - * An array suitable for use with the ajax_render() function. - * - * @see http://docs.jquery.com/Manipulation/remove#expr - */ -function ajax_command_remove($selector) { - return array( - 'command' => 'remove', - 'selector' => $selector, - ); -} - -/** - * Creates a Drupal Ajax 'changed' command. - * - * This command instructs the client to mark each of the elements matched by the - * given selector as 'ajax-changed'. - * - * This command is implemented by Drupal.AjaxCommands.prototype.changed() - * defined in misc/ajax.js. - * - * @param $selector - * A jQuery selector string. If the command is a response to a request from - * an #ajax form element then this value can be NULL. - * @param $asterisk - * An optional CSS selector which must be inside $selector. If specified, - * an asterisk will be appended to the HTML inside the $asterisk selector. - * - * @return - * An array suitable for use with the ajax_render() function. - */ -function ajax_command_changed($selector, $asterisk = '') { - return array( - 'command' => 'changed', - 'selector' => $selector, - 'asterisk' => $asterisk, - ); -} - -/** - * Creates a Drupal Ajax 'css' command. - * - * The 'css' command will instruct the client to use the jQuery css() method - * to apply the CSS arguments to elements matched by the given selector. - * - * This command is implemented by Drupal.AjaxCommands.prototype.css() - * defined in misc/ajax.js. - * - * @param $selector - * A jQuery selector string. If the command is a response to a request from - * an #ajax form element then this value can be NULL. - * @param $argument - * An array of key/value pairs to set in the CSS for the selector. - * - * @return - * An array suitable for use with the ajax_render() function. - * - * @see http://docs.jquery.com/CSS/css#properties - */ -function ajax_command_css($selector, $argument) { - return array( - 'command' => 'css', - 'selector' => $selector, - 'argument' => $argument, - ); -} - -/** - * Creates a Drupal Ajax 'settings' command. - * - * The 'settings' command instructs the client either to use the given array as - * the settings for ajax-loaded content or to extend drupalSettings with the - * given array, depending on the value of the $merge parameter. - * - * This command is implemented by Drupal.AjaxCommands.prototype.settings() - * defined in misc/ajax.js. - * - * @param $argument - * An array of key/value pairs to add to the settings. This will be utilized - * for all commands after this if they do not include their own settings - * array. - * @param $merge - * Whether or not the passed settings in $argument should be merged into the - * global drupalSettings on the page. By default (FALSE), the settings that - * are passed to Drupal.attachBehaviors will not include the global - * drupalSettings. - * - * @return - * An array suitable for use with the ajax_render() function. - */ -function ajax_command_settings($argument, $merge = FALSE) { - return array( - 'command' => 'settings', - 'settings' => $argument, - 'merge' => $merge, - ); -} - -/** - * Creates a Drupal Ajax 'add_css' command. - * - * This method will add css via ajax in a cross-browser compatible way. - * - * This command is implemented by Drupal.AjaxCommands.prototype.add_css() - * defined in misc/ajax.js. - * - * @param $styles - * A string that contains the styles to be added. - * - * @return - * An array suitable for use with the ajax_render() function. - * - * @see misc/ajax.js - */ -function ajax_command_add_css($styles) { - return array( - 'command' => 'add_css', - 'data' => $styles, - ); -} diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php new file mode 100644 index 0000000..5fa31f4 --- /dev/null +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php @@ -0,0 +1,78 @@ +isOk()) { + return $content; + } + + // Allow controllers to return a HtmlFragment or a Response object directly. + if ($content instanceof HtmlFragment) { + $content = $content->getContent(); + } + elseif ($content instanceof Response) { + $content = $content->getContent(); + } + // Most controllers return a render array, but some return a string. + if (!is_array($content)) { + $content = array( + '#markup' => $content, + ); + } + + $response = new AjaxResponse(); + + if (isset($content['#type']) && ($content['#type'] == 'ajax')) { + // Complex Ajax callbacks can return a result that contains an error + // message or a specific set of commands to send to the browser. + $content += element_info('ajax'); + $error = $content['#error']; + if (!empty($error)) { + // Fall back to some default message otherwise use the specific one. + if (!is_string($error)) { + $error = 'An error occurred while handling the request: The server received invalid input.'; + } + $response->addCommand(new AlertCommand($error)); + } + } + + $html = drupal_render($content); + + // The selector for the insert command is NULL as the new content will + // replace the element making the Ajax call. The default 'replaceWith' + // behavior can be changed with #ajax['method']. + $response->addCommand(new InsertCommand(NULL, $html)); + $status_messages = array('#theme' => 'status_messages'); + $output = drupal_render($status_messages); + if (!empty($output)) { + $response->addCommand(new PrependCommand(NULL, $output)); + } + return $response; + } + +} diff --git a/core/lib/Drupal/Core/Controller/AjaxController.php b/core/lib/Drupal/Core/Controller/AjaxController.php index 2f8498e..f0c480e 100644 --- a/core/lib/Drupal/Core/Controller/AjaxController.php +++ b/core/lib/Drupal/Core/Controller/AjaxController.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Controller; use Drupal\Core\Ajax\AjaxResponse; +use Drupal\Core\Ajax\AjaxResponseRenderer; use Drupal\Core\Ajax\InsertCommand; use Drupal\Core\Ajax\PrependCommand; use Drupal\Core\Page\HtmlFragment; @@ -29,13 +30,23 @@ class AjaxController extends ContainerAware { protected $controllerResolver; /** + * The ajax response renderer. + * + * @var \Drupal\Core\Ajax\AjaxResponseRenderer + */ + protected $ajaxRenderer; + + /** * Constructs a new AjaxController instance. * * @param \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver * The controller resolver. + * @param \Drupal\Core\Ajax\AjaxResponseRenderer $ajax_renderer + * The ajax response renderer. */ - public function __construct(ControllerResolverInterface $controller_resolver) { + public function __construct(ControllerResolverInterface $controller_resolver, AjaxResponseRenderer $ajax_renderer) { $this->controllerResolver = $controller_resolver; + $this->ajaxRenderer = $ajax_renderer; } /** @@ -46,45 +57,12 @@ public function __construct(ControllerResolverInterface $controller_resolver) { * @param callable $_content * The callable that returns the content of the ajax response. * - * @return \Symfony\Component\HttpFoundation\Response + * @return \Drupal\Core\Ajax\AjaxResponse * A response object. */ public function content(Request $request, $_content) { $content = $this->getContentResult($request, $_content); - // If there is already an AjaxResponse, then return it without - // manipulation. - if ($content instanceof AjaxResponse && $content->isOk()) { - return $content; - } - - // Allow controllers to return a HtmlFragment or a Response object directly. - if ($content instanceof HtmlFragment) { - $content = $content->getContent(); - } - if ($content instanceof Response) { - $content = $content->getContent(); - } - - // Most controllers return a render array, but some return a string. - if (!is_array($content)) { - $content = array( - '#markup' => $content, - ); - } - - $html = drupal_render($content); - - $response = new AjaxResponse(); - // The selector for the insert command is NULL as the new content will - // replace the element making the ajax call. The default 'replaceWith' - // behavior can be changed with #ajax['method']. - $response->addCommand(new InsertCommand(NULL, $html)); - $status_messages = array('#theme' => 'status_messages'); - $output = drupal_render($status_messages); - if (!empty($output)) { - $response->addCommand(new PrependCommand(NULL, $output)); - } - return $response; + return $this->ajaxRenderer->render($content); } /** diff --git a/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php index 6fb011d..dc9ef35 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php @@ -7,6 +7,7 @@ namespace Drupal\Core\EventSubscriber; +use Drupal\Core\Ajax\AjaxResponseRenderer; use Drupal\Core\Controller\TitleResolverInterface; use Drupal\Core\Page\HtmlPage; use Symfony\Cmf\Component\Routing\RouteObjectInterface; @@ -43,16 +44,26 @@ class ViewSubscriber implements EventSubscriberInterface { protected $titleResolver; /** + * The ajax response renderer. + * + * @var \Drupal\Core\Ajax\AjaxResponseRenderer + */ + protected $ajaxRenderer; + + /** * Constructs a new ViewSubscriber. * * @param \Drupal\Core\ContentNegotiation $negotiation * The content negotiation. * @param \Drupal\Core\Controller\TitleResolverInterface $title_resolver * The title resolver. + * @param \Drupal\Core\Ajax\AjaxResponseRenderer $ajax_renderer + * The ajax response renderer. */ - public function __construct(ContentNegotiation $negotiation, TitleResolverInterface $title_resolver) { + public function __construct(ContentNegotiation $negotiation, TitleResolverInterface $title_resolver, AjaxResponseRenderer $ajax_renderer) { $this->negotiation = $negotiation; $this->titleResolver = $title_resolver; + $this->ajaxRenderer = $ajax_renderer; } /** @@ -118,26 +129,8 @@ public function onJson(GetResponseForControllerResultEvent $event) { return $response; } - public function onAjax(GetResponseForControllerResultEvent $event) { - $page_callback_result = $event->getControllerResult(); - - // Construct the response content from the page callback result. - $commands = ajax_prepare_response($page_callback_result); - $json = ajax_render($commands); - - // Build the actual response object. - $response = new JsonResponse(); - $response->setContent($json); - - return $response; - } - public function onIframeUpload(GetResponseForControllerResultEvent $event) { - $page_callback_result = $event->getControllerResult(); - - // Construct the response content from the page callback result. - $commands = ajax_prepare_response($page_callback_result); - $json = ajax_render($commands); + $response = $event->getResponse(); // Browser IFRAMEs expect HTML. Browser extensions, such as Linkification // and Skype's Browser Highlighter, convert URLs, phone numbers, etc. into @@ -145,7 +138,7 @@ public function onIframeUpload(GetResponseForControllerResultEvent $event) { // JSON data by making it the value of a textarea. // @see http://malsup.com/jquery/form/#file-upload // @see http://drupal.org/node/1009382 - $html = ''; + $html = ''; return new Response($html); } diff --git a/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.php index 4fcd9ea..b9aae48 100644 --- a/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.php +++ b/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.php @@ -37,7 +37,7 @@ public function __construct(ContentNegotiation $negotiation) { * {@inheritdoc} */ public function enhance(array $defaults, Request $request) { - if (empty($defaults['_content']) && $defaults['_controller'] != 'controller.ajax:content' && $this->negotiation->getContentType($request) == 'drupal_ajax') { + if (empty($defaults['_content']) && $defaults['_controller'] != 'controller.ajax:content' && in_array($this->negotiation->getContentType($request), array('drupal_ajax', 'ajax', 'iframeupload'))) { $defaults['_content'] = isset($defaults['_controller']) ? $defaults['_controller'] : NULL; $defaults['_controller'] = 'controller.ajax:content'; } diff --git a/core/modules/action/action.module b/core/modules/action/action.module index 6c4b601..9c4e69e 100644 --- a/core/modules/action/action.module +++ b/core/modules/action/action.module @@ -45,18 +45,6 @@ function action_permission() { } /** - * Implements hook_menu(). - */ -function action_menu() { - $items['admin/config/system/actions'] = array( - 'title' => 'Actions', - 'description' => 'Manage the actions defined for your site.', - 'route_name' => 'action.admin', - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function action_menu_link_defaults() { diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 0ce31c2..d493a6c 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -87,48 +87,6 @@ function aggregator_theme() { } /** - * Implements hook_menu(). - */ -function aggregator_menu() { - $items['admin/config/services/aggregator'] = array( - 'title' => 'Feed aggregator', - 'description' => "Configure which content your site aggregates from other sites, and how often it polls them.", - 'route_name' => 'aggregator.admin_overview', - 'weight' => 10, - ); - $items['admin/config/services/aggregator/remove/%aggregator_feed'] = array( - 'title' => 'Remove items', - 'route_name' => 'aggregator.feed_items_delete', - ); - $items['admin/config/services/aggregator/update/%aggregator_feed'] = array( - 'title' => 'Update items', - 'route_name' => 'aggregator.feed_refresh', - ); - $items['aggregator'] = array( - 'title' => 'Feed aggregator', - 'weight' => 5, - 'route_name' => 'aggregator.page_last', - ); - $items['aggregator/sources'] = array( - 'title' => 'Sources', - 'route_name' => 'aggregator.sources', - ); - $items['aggregator/sources/%aggregator_feed'] = array( - 'route_name' => 'aggregator.feed_view', - ); - $items['admin/config/services/aggregator/edit/feed/%aggregator_feed'] = array( - 'title' => 'Edit feed', - 'route_name' => 'aggregator.feed_edit', - ); - $items['admin/config/services/aggregator/delete/feed/%aggregator_feed'] = array( - 'title' => 'Delete feed', - 'route_name' => 'aggregator.feed_delete', - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function aggregator_menu_link_defaults() { diff --git a/core/modules/ban/ban.module b/core/modules/ban/ban.module index 7d09e7c..e45ed13 100644 --- a/core/modules/ban/ban.module +++ b/core/modules/ban/ban.module @@ -38,23 +38,6 @@ function ban_permission() { } /** - * Implements hook_menu(). - */ -function ban_menu() { - $items['admin/config/people/ban'] = array( - 'title' => 'IP address bans', - 'description' => 'Manage banned IP addresses.', - 'route_name' => 'ban.admin_page', - 'weight' => 10, - ); - $items['admin/config/people/ban/delete/%'] = array( - 'title' => 'Delete IP address', - 'route_name' => 'ban.delete', - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function ban_menu_link_defaults() { diff --git a/core/modules/block/block.module b/core/modules/block/block.module index ba915a9..0313089 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -94,29 +94,6 @@ function block_permission() { } /** - * Implements hook_menu(). - * - * @todo Clarify the documentation for the per-plugin block admin links. - */ -function block_menu() { - $items['admin/structure/block'] = array( - 'title' => 'Block layout', - 'description' => 'Configure what block content appears in your site\'s sidebars and other regions.', - 'route_name' => 'block.admin_display', - ); - $items['admin/structure/block/manage/%block'] = array( - 'title' => 'Configure block', - 'route_name' => 'block.admin_edit', - ); - $items['admin/structure/block/add/%/%'] = array( - 'title' => 'Place block', - 'type' => MENU_VISIBLE_IN_BREADCRUMB, - 'route_name' => 'block.admin_add', - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function block_menu_link_defaults() { diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index cdf90c7..14d5991 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -57,33 +57,6 @@ function custom_block_menu_local_tasks(&$data, $route_name) { } /** - * Implements hook_menu(). - */ -function custom_block_menu() { - $items['admin/structure/block/custom-blocks'] = array( - 'title' => 'Custom block library', - 'description' => 'Manage custom blocks.', - 'route_name' => 'custom_block.list', - 'type' => MENU_NORMAL_ITEM, - ); - - $items['admin/structure/block/custom-blocks/manage/%custom_block_type'] = array( - 'title' => 'Edit custom block type', - 'title callback' => 'entity_page_label', - 'title arguments' => array(5), - 'route_name' => 'custom_block.type_edit', - ); - - $items['block/add'] = array( - 'title' => 'Add custom block', - 'description' => 'Add custom block', - 'route_name' => 'custom_block.add_page', - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function custom_block_menu_link_defaults() { @@ -92,6 +65,11 @@ function custom_block_menu_link_defaults() { 'description' => 'Add custom block', 'route_name' => 'custom_block.add_page', ); + $items['custom_block.list'] = array( + 'link_title' => 'Custom block library', + 'parent' => 'block.admin.structure', + 'description' => 'Manage custom blocks.', + ); return $links; } diff --git a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module index 7186098..8c53053 100644 --- a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module +++ b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module @@ -66,17 +66,3 @@ function custom_block_test_custom_block_insert(CustomBlock $custom_block) { throw new Exception('Test exception for rollback.'); } } - -/** - * Implements hook_menu(). - */ -function custom_block_test_menu() { - $items = array(); - // Add a block-view callback. - $items['custom-block/%custom_block'] = array( - 'title callback' => 'entity_page_label', - 'title arguments' => array(1), - 'route_name' => 'custom_block_test.custom_block_view', - ); - return $items; -} diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 9bc7b72..25de14f 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -159,28 +159,6 @@ function book_node_links_alter(array &$node_links, NodeInterface $node, array &$ } /** - * Implements hook_menu(). - */ -function book_menu() { - $items['admin/structure/book'] = array( - 'title' => 'Books', - 'description' => "Manage your site's book outlines.", - 'route_name' => 'book.admin', - ); - $items['book'] = array( - 'title' => 'Books', - 'route_name' => 'book.render', - 'type' => MENU_SUGGESTED_ITEM, - ); - $items['node/%node/outline/remove'] = array( - 'title' => 'Remove from outline', - 'route_name' => 'book.remove', - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function book_menu_link_defaults() { diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 1f5201e..c72ea6b 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -211,12 +211,12 @@ function comment_menu_link_defaults() { } /** - * Implements hook_menu_alter(). + * Implements hook_menu_link_defaults_alter() */ -function comment_menu_alter(&$items) { - if (isset($items['admin/content'])) { +function comment_menu_links_defaults_alter(&$links) { + if (isset($links['node.admin.content'])) { // Add comments to the description for admin/content if any. - $items['admin/content']['description'] = 'Administer content and comments.'; + $links['node.admin.content']['description'] = 'Administer content and comments.'; } } diff --git a/core/modules/config/config.module b/core/modules/config/config.module index 3cb71e6..776a9fc 100644 --- a/core/modules/config/config.module +++ b/core/modules/config/config.module @@ -58,19 +58,6 @@ function config_file_download($uri) { } /** - * Implements hook_menu(). - */ -function config_menu() { - $items['admin/config/development/configuration'] = array( - 'title' => 'Configuration management', - 'description' => 'Import, export, or synchronize your site configuration.', - 'route_name' => 'config.sync', - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function config_menu_link_defaults() { diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index 0c3b782..0a583ca 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -11,32 +11,6 @@ require_once dirname(__FILE__) . '/config_test.hooks.inc'; /** - * Implements hook_menu(). - */ -function config_test_menu() { - $items['admin/structure/config_test'] = array( - 'title' => 'Test configuration', - 'route_name' => 'config_test.list_page', - ); - $items['admin/structure/config_test/manage/%config_test'] = array( - 'route_name' => 'config_test.entity', - ); - $items['admin/structure/config_test/manage/%config_test/delete'] = array( - 'title' => 'Delete', - 'route_name' => 'config_test.entity_delete', - ); - $items['admin/structure/config_test/manage/%config_test/enable'] = array( - 'title' => 'Enable', - 'route_name' => 'config_test.entity_enable', - ); - $items['admin/structure/config_test/manage/%config_test/disable'] = array( - 'title' => 'Disable', - 'route_name' => 'config_test.entity_disable', - ); - return $items; -} - -/** * Loads a ConfigTest object. * * @param string $id diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index da89447..b65ea84 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -32,20 +32,6 @@ function config_translation_help($path) { } /** - * Implements hook_menu(). - */ -function config_translation_menu() { - $items = array(); - $items['admin/config/regional/config-translation'] = array( - 'title' => 'Configuration translation', - 'description' => 'Translate the configuration.', - 'route_name' => 'config_translation.mapper_list', - 'weight' => 30, - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function config_translation_menu_link_defaults() { diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index bb967db..20db5c3 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -52,34 +52,6 @@ function contact_permission() { } /** - * Implements hook_menu(). - */ -function contact_menu() { - $items['admin/structure/contact'] = array( - 'title' => 'Contact form categories', - 'description' => 'Create a system contact form and set up categories for the form to use.', - 'route_name' => 'contact.category_list', - ); - $items['admin/structure/contact/manage/%contact_category'] = array( - 'title' => 'Edit contact category', - 'route_name' => 'contact.category_edit', - ); - - $items['contact'] = array( - 'title' => 'Contact', - 'route_name' => 'contact.site_page', - 'menu_name' => 'footer', - 'type' => MENU_SUGGESTED_ITEM, - ); - $items['contact/%contact_category'] = array( - 'title' => 'Contact category form', - 'route_name' => 'contact.site_page_category', - 'type' => MENU_VISIBLE_IN_BREADCRUMB, - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function contact_menu_link_defaults() { diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index b210091..cfbe0f0 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -247,10 +247,6 @@ function content_translation_menu() { * https://drupal.org/node/1987882 and https://drupal.org/node/2047633. */ function content_translation_menu_alter(array &$items) { - // Clarify where translation settings are located. - $items['admin/config/regional/content-language']['title'] = 'Content language and translation'; - $items['admin/config/regional/content-language']['description'] = 'Configure language and translation support for content.'; - // Check that the declared menu base paths are actually valid. foreach (\Drupal::entityManager()->getDefinitions() as $entity_type => $info) { if (content_translation_enabled($entity_type)) { diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module index 4060d63..cd8e2c0 100644 --- a/core/modules/dblog/dblog.module +++ b/core/modules/dblog/dblog.module @@ -37,42 +37,6 @@ function dblog_help($path, $arg) { } /** - * Implements hook_menu(). - */ -function dblog_menu() { - $items['admin/reports/dblog'] = array( - 'title' => 'Recent log messages', - 'description' => 'View events that have recently been logged.', - 'route_name' => 'dblog.overview', - 'weight' => -1, - ); - $items['admin/reports/page-not-found'] = array( - 'title' => "Top 'page not found' errors", - 'description' => "View 'page not found' errors (404s).", - 'route_name' => 'dblog.page_not_found', - ); - $items['admin/reports/access-denied'] = array( - 'title' => "Top 'access denied' errors", - 'description' => "View 'access denied' errors (403s).", - 'route_name' => 'dblog.access_denied', - ); - $items['admin/reports/event/%'] = array( - 'title' => 'Details', - 'route_name' => 'dblog.event', - ); - - if (\Drupal::moduleHandler()->moduleExists('search')) { - $items['admin/reports/search'] = array( - 'title' => 'Top search phrases', - 'description' => 'View most popular search phrases.', - 'route_name' => 'dblog.search', - ); - } - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function dblog_menu_link_defaults() { diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 1358910..3a2b4ec 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -36,19 +36,11 @@ function editor_help($path, $arg) { } /** - * Implements hook_menu_alter(). + * Implements hook_menu_link_defaults_alter(). * * Rewrites the menu entries for filter module that relate to the configuration * of text editors. */ -function editor_menu_alter(&$items) { - $items['admin/config/content/formats']['title'] = 'Text formats and editors'; - $items['admin/config/content/formats']['description'] = 'Configure how user-contributed content is filtered and formatted, as well as the text editor user interface (WYSIWYGs or toolbars).'; -} - -/** - * Implements hook_menu_link_defaults_alter(). - */ function editor_menu_link_defaults_alter(array &$links) { $links['filter.admin.formats']['link_title'] = 'Text formats and editors'; $links['filter.admin.formats']['description'] = 'Configure how user-contributed content is filtered and formatted, as well as the text editor user interface (WYSIWYGs or toolbars).'; diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index 5b3f414..cd2a62d 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -45,57 +45,6 @@ function entity_permission() { } /** - * Implements hook_menu(). - */ -function entity_menu() { - $items = array(); - - $items['admin/structure/display-modes'] = array( - 'title' => 'Display modes', - 'description' => 'Configure what displays are available for your content and forms.', - 'route_name' => 'entity.display_mode', - ); - - // View modes. - $items['admin/structure/display-modes/view'] = array( - 'title' => 'View modes', - 'description' => 'Manage custom view modes.', - 'route_name' => 'entity.view_mode_list', - ); - $items['admin/structure/display-modes/view/add'] = array( - 'title' => 'Add view mode', - 'route_name' => 'entity.view_mode_add', - 'type' => MENU_SIBLING_LOCAL_TASK, - ); - $items['admin/structure/display-modes/view/add/%'] = array( - 'route_name' => 'entity.view_mode_add_type', - ); - $items['admin/structure/display-modes/view/manage/%/delete'] = array( - 'route_name' => 'entity.view_mode_delete', - ); - - // Form modes. - $items['admin/structure/display-modes/form'] = array( - 'title' => 'Form modes', - 'description' => 'Manage custom form modes.', - 'route_name' => 'entity.form_mode_list', - ); - $items['admin/structure/display-modes/form/add'] = array( - 'title' => 'Add form mode', - 'route_name' => 'entity.form_mode_add', - 'type' => MENU_SIBLING_LOCAL_TASK, - ); - $items['admin/structure/display-modes/form/add/%'] = array( - 'route_name' => 'entity.form_mode_add_type', - ); - $items['admin/structure/display-modes/form/manage/%/delete'] = array( - 'route_name' => 'entity.form_mode_delete', - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function entity_menu_link_defaults() { diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index 8215416..5b072ae 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -37,19 +37,6 @@ function field_test_permission() { } /** - * Implements hook_menu(). - */ -function field_test_menu() { - $items = array(); - $items['test-entity/nested/%entity_test/%entity_test'] = array( - 'title' => 'Nested entity form', - 'route_name' => 'field_test.entity_nested_form', - ); - - return $items; -} - -/** * Store and retrieve keyed data for later verification by unit tests. * * This function is a simple in-memory key-value store with the diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index ef392cf..5ad0b01 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -53,20 +53,6 @@ function field_ui_help($path, $arg) { } /** - * Implements hook_menu(). - */ -function field_ui_menu() { - $items['admin/reports/fields'] = array( - 'title' => 'Field list', - 'description' => 'Overview of fields on all entity types.', - 'route_name' => 'field_ui.list', - 'type' => MENU_NORMAL_ITEM, - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function field_ui_menu_link_defaults() { diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 710c59f..68005c3 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -118,36 +118,6 @@ function filter_element_info() { } /** - * Implements hook_menu(). - */ -function filter_menu() { - $items['filter/tips'] = array( - 'title' => 'Compose tips', - 'type' => MENU_SUGGESTED_ITEM, - 'route_name' => 'filter.tips_all', - ); - $items['filter/tips/%'] = array( - 'title' => 'Compose tips', - 'route_name' => 'filter.tips', - ); - $items['admin/config/content/formats'] = array( - 'title' => 'Text formats', - 'description' => 'Configure how content input by users is filtered, including allowed HTML tags. Also allows enabling of module-provided filters.', - 'route_name' => 'filter.admin_overview', - ); - $items['admin/config/content/formats/manage/%'] = array( - 'title callback' => 'entity_page_label', - 'title arguments' => array(5), - 'route_name' => 'filter.format_edit', - ); - $items['admin/config/content/formats/manage/%/disable'] = array( - 'title' => 'Disable text format', - 'route_name' => 'filter.admin_disable', - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function filter_menu_link_defaults() { diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 7179120..1cd01c2 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -98,40 +98,6 @@ function forum_theme() { } /** - * Implements hook_menu(). - */ -function forum_menu() { - $items['forum'] = array( - 'title' => 'Forums', - 'route_name' => 'forum.index', - ); - $items['forum/%forum'] = array( - 'title' => 'Forums', - 'title callback' => 'entity_page_label', - 'title arguments' => array(1), - 'route_name' => 'forum.page', - ); - $items['admin/structure/forum'] = array( - 'title' => 'Forums', - 'description' => 'Control forum hierarchy settings.', - 'route_name' => 'forum.overview', - ); - $items['admin/structure/forum/edit/container/%taxonomy_term'] = array( - 'title' => 'Edit container', - 'route_name' => 'forum.edit_container', - ); - $items['admin/structure/forum/edit/forum/%taxonomy_term'] = array( - 'title' => 'Edit forum', - 'route_name' => 'forum.edit_forum', - ); - $items['admin/structure/forum/delete/forum/%taxonomy_term'] = array( - 'title' => 'Delete forum', - 'route_name' => 'forum.delete', - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function forum_menu_link_defaults() { diff --git a/core/modules/help/help.module b/core/modules/help/help.module index 6d07405..89e0f31 100644 --- a/core/modules/help/help.module +++ b/core/modules/help/help.module @@ -6,25 +6,6 @@ */ /** - * Implements hook_menu(). - */ -function help_menu() { - $items['admin/help'] = array( - 'title' => 'Help', - 'description' => 'Reference for usage, configuration, and modules.', - 'route_name' => 'help.main', - 'weight' => 9, - ); - - $items['admin/help/%'] = array( - 'route_name' => 'help.page', - 'type' => MENU_VISIBLE_IN_BREADCRUMB, - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function help_menu_link_defaults() { diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 3751b8c..1dac767 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -85,41 +85,6 @@ function image_help($path, $arg) { } /** - * Implements hook_menu(). - */ -function image_menu() { - $items = array(); - - $items['admin/config/media/image-styles'] = array( - 'title' => 'Image styles', - 'description' => 'Configure styles that can be used for resizing or adjusting images on display.', - 'route_name' => 'image.style_list', - ); - $items['admin/config/media/image-styles/manage/%image_style'] = array( - 'title' => 'Edit style', - 'description' => 'Configure an image style.', - 'route_name' => 'image.style_edit', - ); - $items['admin/config/media/image-styles/manage/%/effects/%'] = array( - 'title' => 'Edit image effect', - 'description' => 'Edit an existing effect within a style.', - 'route_name' => 'image.effect_edit_form', - ); - $items['admin/config/media/image-styles/manage/%image_style/effects/%/delete'] = array( - 'title' => 'Delete image effect', - 'description' => 'Delete an existing effect from a style.', - 'route_name' => 'image.effect_delete', - ); - $items['admin/config/media/image-styles/manage/%/add/%'] = array( - 'title' => 'Add image effect', - 'description' => 'Add a new effect to a style.', - 'route_name' => 'image.effect_add_form', - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function image_menu_link_defaults() { diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 8d0faab..7262894 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -69,29 +69,6 @@ function language_help($path, $arg) { } /** - * Implements hook_menu(). - */ -function language_menu() { - // Base language management and configuration. - $items['admin/config/regional/language'] = array( - 'title' => 'Languages', - 'description' => 'Configure languages for content and the user interface.', - 'route_name' => 'language.admin_overview', - 'weight' => 0, - ); - - // Content language settings. - $items['admin/config/regional/content-language'] = array( - 'title' => 'Content language', - 'description' => 'Configure language support for content.', - 'route_name' => 'language.content_settings_page', - 'weight' => 10, - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function language_menu_link_defaults() { diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 21748ae..336adba 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -167,27 +167,6 @@ function locale_help($path, $arg) { } /** - * Implements hook_menu(). - */ -function locale_menu() { - // Translation functionality. - $items['admin/config/regional/translate'] = array( - 'title' => 'User interface translation', - 'description' => 'Translate the built-in user interface.', - 'route_name' => 'locale.translate_page', - 'weight' => 15, - ); - - $items['admin/reports/translations'] = array( - 'title' => 'Available translation updates', - 'route_name' => 'locale.translate_status', - 'description' => 'Get a status report about available interface translations for your installed modules and themes.', - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function locale_menu_link_defaults() { diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index d4a8857..e511f3e 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -63,36 +63,6 @@ function menu_permission() { } /** - * Implements hook_menu(). - */ -function menu_menu() { - $items['admin/structure/menu'] = array( - 'title' => 'Menus', - 'description' => 'Add new menus to your site, edit existing menus, and rename and reorganize menu links.', - 'route_name' => 'menu.overview_page', - ); - $items['admin/structure/menu/manage/%menu'] = array( - 'title' => 'Edit menu', - 'route_name' => 'menu.menu_edit', - 'title callback' => 'entity_page_label', - 'title arguments' => array(4), - ); - $items['admin/structure/menu/item/%menu_link/edit'] = array( - 'title' => 'Edit menu link', - 'route_name' => 'menu.link_edit', - ); - $items['admin/structure/menu/item/%menu_link/reset'] = array( - 'title' => 'Reset menu link', - 'route_name' => 'menu.link_reset', - ); - $items['admin/structure/menu/item/%menu_link/delete'] = array( - 'title' => 'Delete menu link', - 'route_name' => 'menu.link_delete', - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function menu_menu_link_defaults() { diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 9cbb1f9..0bdf3ed 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -927,53 +927,6 @@ function _node_revision_access(EntityInterface $node, $op = 'view', $account = N } /** - * Implements hook_menu(). - */ -function node_menu() { - $items['admin/content'] = array( - 'title' => 'Content', - 'description' => 'Find and manage content.', - 'route_name' => 'node.content_overview', - 'weight' => -10, - ); - - $items['admin/structure/types'] = array( - 'title' => 'Content types', - 'description' => 'Manage content types, including default status, front page promotion, comment settings, etc.', - 'route_name' => 'node.overview_types', - ); - $items['node/add'] = array( - 'title' => 'Add content', - 'route_name' => 'node.add_page', - ); - $items['node/add/%node_type'] = array( - 'description callback' => 'node_type_get_description', - 'description arguments' => array(2), - 'route_name' => 'node.add', - ); - $items['node/%node'] = array( - 'title callback' => 'node_page_title', - 'title arguments' => array(1), - // The controller also sets the #title in case the routes' title is - // overridden by a menu link. - 'route_name' => 'node.view', - ); - $items['node/%node/revisions/%node_revision/view'] = array( - 'title' => 'Revisions', - 'route_name' => 'node.revision_show', - ); - $items['node/%node/revisions/%node_revision/revert'] = array( - 'title' => 'Revert to earlier revision', - 'route_name' => 'node.revision_revert_confirm', - ); - $items['node/%node/revisions/%node_revision/delete'] = array( - 'title' => 'Delete earlier revision', - 'route_name' => 'node.revision_delete_confirm', - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function node_menu_link_defaults() { diff --git a/core/modules/path/path.module b/core/modules/path/path.module index 80eeace..e9257ca 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -54,28 +54,6 @@ function path_permission() { } /** - * Implements hook_menu(). - */ -function path_menu() { - $items['admin/config/search/path'] = array( - 'title' => 'URL aliases', - 'description' => "Change your site's URL paths by aliasing them.", - 'route_name' => 'path.admin_overview', - 'weight' => -5, - ); - $items['admin/config/search/path/edit/%path'] = array( - 'title' => 'Edit alias', - 'route_name' => 'path.admin_edit', - ); - $items['admin/config/search/path/delete/%path'] = array( - 'title' => 'Delete alias', - 'route_name' => 'path.delete', - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function path_menu_link_defaults() { diff --git a/core/modules/picture/picture.module b/core/modules/picture/picture.module index 9e5e4a3..438abed 100644 --- a/core/modules/picture/picture.module +++ b/core/modules/picture/picture.module @@ -48,30 +48,6 @@ function picture_permission() { } /** - * Implements hook_menu(). - */ -function picture_menu() { - $items = array(); - - $items['admin/config/media/picturemapping'] = array( - 'title' => 'Picture Mappings', - 'description' => 'Manage picture mappings', - 'weight' => 10, - 'route_name' => 'picture.mapping_page', - ); - $items['admin/config/media/picturemapping/%picture_mapping'] = array( - 'title' => 'Edit picture mapping', - 'route_name' => 'picture.mapping_page_edit', - ); - $items['admin/config/media/picturemapping/%picture_mapping/duplicate'] = array( - 'title' => 'Duplicate picture mapping', - 'route_name' => 'picture.mapping_page_duplicate', - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function picture_menu_link_defaults() { diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 11a5e00..2a4aa70 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -144,30 +144,6 @@ function search_preprocess_block(&$variables) { } /** - * Implements hook_menu(). - */ -function search_menu() { - $items['search'] = array( - 'title' => 'Search', - 'type' => MENU_SUGGESTED_ITEM, - 'route_name' => 'search.view', - ); - $items['admin/config/search/settings'] = array( - 'title' => 'Search settings', - 'description' => 'Configure relevance settings for search and other indexing options.', - 'route_name' => 'search.settings', - 'weight' => -10, - ); - $items['admin/config/search/settings/reindex'] = array( - 'title' => 'Clear index', - 'route_name' => 'search.reindex_confirm', - 'type' => MENU_VISIBLE_IN_BREADCRUMB, - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function search_menu_link_defaults() { diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index a988cf4..fa7971e 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -60,33 +60,6 @@ function shortcut_permission() { } /** - * Implements hook_menu(). - */ -function shortcut_menu() { - $items['admin/config/user-interface/shortcut'] = array( - 'title' => 'Shortcuts', - 'description' => 'Add and modify shortcut sets.', - 'route_name' => 'shortcut.set_admin', - ); - $items['admin/config/user-interface/shortcut/manage/%shortcut_set'] = array( - 'title' => 'Edit shortcuts', - 'route_name' => 'shortcut.set_customize', - 'title callback' => 'entity_page_label', - 'title arguments' => array(5), - ); - $items['admin/config/user-interface/shortcut/link/%shortcut'] = array( - 'title' => 'Edit shortcut', - 'route_name' => 'shortcut.link_edit', - ); - $items['admin/config/user-interface/shortcut/link/%shortcut/delete'] = array( - 'title' => 'Delete shortcut', - 'route_name' => 'shortcut.link_delete', - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function shortcut_menu_link_defaults() { diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index b284941..fff0ace 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -1667,7 +1667,8 @@ protected function drupalProcessAjaxResponse($content, array $ajax_response, arr } // @todo Ajax commands can target any jQuery selector, but these are // hard to fully emulate with XPath. For now, just handle 'head' - // and 'body', since these are used by ajax_render(). + // and 'body', since these are used by + // \Drupal\Core\Ajax\AjaxResponse::ajaxRender(). elseif (in_array($command['selector'], array('head', 'body'))) { $wrapperNode = $xpath->query('//' . $command['selector'])->item(0); } diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index c6b53bf..c7f549b 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -30,24 +30,6 @@ function simpletest_help($path, $arg) { } /** - * Implements hook_menu(). - */ -function simpletest_menu() { - $items['admin/config/development/testing'] = array( - 'title' => 'Testing', - 'description' => 'Run tests against Drupal core and your modules. These tests help assure that your site code is working as designed.', - 'route_name' => 'simpletest.test_form', - 'weight' => -5, - ); - $items['admin/config/development/testing/results/%'] = array( - 'title' => 'Test result', - 'description' => 'View result of tests.', - 'route_name' => 'simpletest.result_form', - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function simpletest_menu_link_defaults() { diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index a8a0105..47f8980 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -79,19 +79,6 @@ function statistics_node_links_alter(array &$node_links, NodeInterface $entity, } /** - * Implements hook_menu(). - */ -function statistics_menu() { - $items['admin/config/system/statistics'] = array( - 'title' => 'Statistics', - 'description' => 'Control details about what and how your site logs content statistics.', - 'route_name' => 'statistics.settings', - 'weight' => -15, - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function statistics_menu_link_defaults() { diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxTestBase.php index a196f85..24a572a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxTestBase.php @@ -24,22 +24,22 @@ /** * Asserts the array of Ajax commands contains the searched command. * - * The Ajax framework, via the ajax_render() function, returns an array of - * commands. This array sometimes includes commands automatically provided by - * the framework in addition to commands returned by a particular page - * callback. During testing, we're usually interested that a particular - * command is present, and don't care whether other commands precede or - * follow the one we're interested in. Additionally, the command we're - * interested in may include additional data that we're not interested in. - * Therefore, this function simply asserts that one of the commands in - * $haystack contains all of the keys and values in $needle. Furthermore, if - * $needle contains a 'settings' key with an array value, we simply assert - * that all keys and values within that array are present in the command we're - * checking, and do not consider it a failure if the actual command contains - * additional settings that aren't part of $needle. + * An AjaxResponse object stores an array of Ajax commands. This array + * sometimes includes commands automatically provided by the framework in + * addition to commands returned by a particular controller. During testing, + * we're usually interested that a particular command is present, and don't + * care whether other commands precede or follow the one we're interested in. + * Additionally, the command we're interested in may include additional data + * that we're not interested in. Therefore, this function simply asserts that + * one of the commands in $haystack contains all of the keys and values in + * $needle. Furthermore, if $needle contains a 'settings' key with an array + * value, we simply assert that all keys and values within that array are + * present in the command we're checking, and do not consider it a failure if + * the actual command contains additional settings that aren't part of + * $needle. * * @param $haystack - * An array of Ajax commands returned by the server. + * An array of rendered Ajax commands returned by the server. * @param $needle * Array of info we're expecting in one of those commands. * @param $message diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php index b70a1e6..aa51ab5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/FrameworkTest.php @@ -27,14 +27,14 @@ public static function getInfo() { } /** - * Ensures ajax_render() returns JavaScript settings from the page request. + * Ensures \Drupal\Core\Ajax\AjaxResponse::ajaxRender() returns JavaScript settings from the page request. */ public function testAJAXRender() { // Verify that settings command is generated when JavaScript settings are // set via _drupal_add_js(). $commands = $this->drupalGetAJAX('ajax-test/render'); $expected = new SettingsCommand(array('ajax' => 'test'), TRUE); - $this->assertCommand($commands, $expected->render(), 'ajax_render() loads settings added with _drupal_add_js().'); + $this->assertCommand($commands, $expected->render(), '\Drupal\Core\Ajax\AjaxResponse::ajaxRender() loads settings added with _drupal_add_js().'); } /** @@ -101,7 +101,7 @@ public function testOrder() { } /** - * Tests behavior of ajax_render_error(). + * Tests the behavior of an error alert command. */ public function testAJAXRenderError() { // Verify custom error message. diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 6c83611..c88b9a2 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -399,17 +399,18 @@ function hook_css_alter(&$css) { } /** - * Alter the commands that are sent to the user through the Ajax framework. + * Alter the Ajax command data that is sent to the client. * - * @param $commands - * An array of all commands that will be sent to the user. + * @param \Drupal\Core\Ajax\CommandInterface[] $data + * An array of all the rendered commands that will be sent to the client. * - * @see ajax_render() + * @see \Drupal\Core\Ajax\AjaxResponse::ajaxRender() */ -function hook_ajax_render_alter($commands) { +function hook_ajax_render_alter(array &$data) { // Inject any new status messages into the content area. $status_messages = array('#theme' => 'status_messages'); - $commands[] = ajax_command_prepend('#block-system-main .content', drupal_render($status_messages)); + $command = new \Drupal\Core\Ajax\PrependCommand('#block-system-main .content', drupal_render($status_messages)); + $data[] = $command->render(); } /** diff --git a/core/modules/system/tests/modules/ajax_test/ajax_test.module b/core/modules/system/tests/modules/ajax_test/ajax_test.module index 2ea9eb9..c9e7918 100644 --- a/core/modules/system/tests/modules/ajax_test/ajax_test.module +++ b/core/modules/system/tests/modules/ajax_test/ajax_test.module @@ -21,11 +21,12 @@ function ajax_test_system_theme_info() { } /** - * Menu callback: Returns an element suitable for use by ajax_render(). + * Menu callback: Returns an element suitable for use by + * \Drupal\Core\Ajax\AjaxResponse::ajaxRender(). * - * Additionally ensures that ajax_render() incorporates JavaScript settings - * generated during the page request by invoking _drupal_add_js() with a dummy - * setting. + * Additionally ensures that \Drupal\Core\Ajax\AjaxResponse::ajaxRender() + * incorporates JavaScript settings generated during the page request by + * invoking drupal_add_js() with a dummy setting. * * @deprecated \Drupal\ajax_test\Controller\AjaxTestController::render() */ diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module index 6bb9a78..2810178 100644 --- a/core/modules/system/tests/modules/module_test/module_test.module +++ b/core/modules/system/tests/modules/module_test/module_test.module @@ -69,25 +69,6 @@ function module_test_hook_info() { } /** - * Implements hook_menu(). - */ -function module_test_menu() { - $items['module-test/hook-dynamic-loading-invoke'] = array( - 'title' => 'Test hook dynamic loading (invoke)', - 'route_name' => 'module_test.dynamic_invoke', - ); - $items['module-test/hook-dynamic-loading-invoke-all'] = array( - 'title' => 'Test hook dynamic loading (invoke_all)', - 'route_name' => 'module_test.dynamic_invoke_all', - ); - $items['module-test/class-loading'] = array( - 'title' => 'Test loading a class from another module', - 'route_name' => 'module_test.class_loading', - ); - return $items; -} - -/** * Page callback for 'hook dynamic loading' test. * * If the hook is dynamically loaded correctly, the menu callback should diff --git a/core/modules/system/tests/modules/plugin_test/plugin_test.module b/core/modules/system/tests/modules/plugin_test/plugin_test.module index 6a33894..147e052 100644 --- a/core/modules/system/tests/modules/plugin_test/plugin_test.module +++ b/core/modules/system/tests/modules/plugin_test/plugin_test.module @@ -14,14 +14,3 @@ function plugin_test_plugin_test_alter(&$definitions) { } $definitions['user_login']['altered_single'] = TRUE; } - -/** - * Implements hook_menu(). - */ -function plugin_test_menu() { - $items = array(); - $items['plugin_definition_test'] = array( - 'route_name' => 'plugin_test.definition', - ); - return $items; -} diff --git a/core/modules/system/tests/modules/test_page_test/test_page_test.module b/core/modules/system/tests/modules/test_page_test/test_page_test.module index 7933a85..93c10c5 100644 --- a/core/modules/system/tests/modules/test_page_test/test_page_test.module +++ b/core/modules/system/tests/modules/test_page_test/test_page_test.module @@ -1,18 +1,6 @@ 'Test front page', - 'route_name' => 'test_page_test.test_page', - ); - - return $items; -} - -/** * Page callback: Returns a test page and sets the title. * * @deprecated Use \Drupal\test_page_test\Controller\TestPageTestController::testPage() diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index bdb1404..4fdfd09 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -64,27 +64,6 @@ function theme_test_system_theme_info() { } /** - * Implements hook_menu(). - */ -function theme_test_menu() { - $items['theme-test/suggestion'] = array( - 'route_name' => 'theme_test.suggestion', - 'theme callback' => '_theme_custom_theme', - 'type' => MENU_CALLBACK, - ); - $items['theme-test/alter'] = array( - 'theme callback' => '_theme_custom_theme', - 'route_name' => 'theme_test.alter', - 'type' => MENU_CALLBACK, - ); - $items['theme-test/function-template-overridden'] = array( - 'theme callback' => '_theme_custom_theme', - 'route_name' => 'theme_test.function_template_override', - ); - return $items; -} - -/** * Implements hook_preprocess_HOOK() for HTML document templates. */ function theme_test_preprocess_html(&$variables) { diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index c1aa72e..0266bca 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -229,33 +229,6 @@ function taxonomy_theme() { } /** - * Implements hook_menu(). - */ -function taxonomy_menu() { - $items['admin/structure/taxonomy'] = array( - 'title' => 'Taxonomy', - 'description' => 'Manage tagging, categorization, and classification of your content.', - 'route_name' => 'taxonomy.vocabulary_list', - ); - - $items['taxonomy/term/%taxonomy_term'] = array( - 'title' => 'Taxonomy term', - 'title callback' => 'taxonomy_term_title', - 'title arguments' => array(2), - 'route_name' => 'taxonomy.term_page', - ); - $items['taxonomy/term/%taxonomy_term/feed'] = array( - 'title' => 'Taxonomy term', - 'title callback' => 'taxonomy_term_title', - 'title arguments' => array(2), - 'route_name' => 'taxonomy.term_feed', - 'type' => MENU_CALLBACK, - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function taxonomy_menu_link_defaults() { diff --git a/core/modules/tour/tests/tour_test/tour_test.module b/core/modules/tour/tests/tour_test/tour_test.module index 0df3e57..3b1ca24 100644 --- a/core/modules/tour/tests/tour_test/tour_test.module +++ b/core/modules/tour/tests/tour_test/tour_test.module @@ -18,18 +18,19 @@ function tour_test_admin_paths() { } /** - * Implements hook_menu(). + * Implements hook_menu_link_defaults(). */ -function tour_test_menu() { - $items['tour-test-1'] = array( +function hook_menu_link_defaults() { + $links['tour_test.1'] = array( 'route_name' => 'tour_test.1', - 'title' => 'Tour test 1' + 'link_title' => 'Tour test 1' ); - $items['tour-test-2/subpath'] = array( + $links['tour_test.2'] = array( 'route_name' => 'tour_test.2', - 'title' => 'Tour test 2' + 'link_title' => 'Tour test 2' ); - return $items; + + return $links; } /** diff --git a/core/modules/update/update.module b/core/modules/update/update.module index adf6ba3..4b0484d 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -162,22 +162,6 @@ function update_library_info() { } /** - * Implements hook_menu(). - */ -function update_menu() { - $items = array(); - - $items['admin/reports/updates'] = array( - 'title' => 'Available updates', - 'description' => 'Get a status report about available updates for your installed modules and themes.', - 'route_name' => 'update.status', - 'weight' => -50, - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function update_menu_link_defaults() { diff --git a/core/modules/user/user.module b/core/modules/user/user.module index b6b9f53..a6d5f83 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -706,88 +706,6 @@ function user_register_access() { } /** - * Implements hook_menu(). - */ -function user_menu() { - // Registration and login pages. - $items['user'] = array( - 'title' => 'User account', - 'title callback' => 'user_menu_title', - 'weight' => -10, - 'route_name' => 'user.page', - 'menu_name' => 'account', - ); - - // Since menu_get_ancestors() does not support multiple placeholders in a row, - // this MENU_CALLBACK cannot be removed yet. - $items['user/reset/%/%/%'] = array( - 'title' => 'Reset password', - 'route_name' => 'user.reset', - 'type' => MENU_CALLBACK, - ); - - $items['user/logout'] = array( - 'title' => 'Log out', - 'route_name' => 'user.logout', - 'weight' => 10, - 'menu_name' => 'account', - ); - - // User listing pages. - $items['admin/people'] = array( - 'title' => 'People', - 'description' => 'Manage user accounts, roles, and permissions.', - 'route_name' => 'user.admin_account', - 'position' => 'left', - 'weight' => -4, - ); - - // Permissions and role forms. - $items['admin/people/permissions'] = array( - 'title' => 'Permissions', - 'description' => 'Determine access to features by selecting permissions for roles.', - 'route_name' => 'user.admin_permissions', - 'type' => MENU_SIBLING_LOCAL_TASK, - ); - - $items['admin/people/roles/manage/%user_role'] = array( - 'title' => 'Edit role', - 'route_name' => 'user.role_edit', - ); - - // Administration pages. - $items['admin/config/people'] = array( - 'title' => 'People', - 'description' => 'Configure user accounts.', - 'position' => 'left', - 'weight' => -20, - 'route_name' => 'user.admin_index', - ); - - $items['admin/config/people/accounts'] = array( - 'title' => 'Account settings', - 'description' => 'Configure default behavior of users, including registration requirements, e-mails, and fields.', - 'weight' => -10, - 'route_name' => 'user.account_settings', - ); - - $items['user/%user'] = array( - 'title' => 'My account', - 'title callback' => 'user_page_title', - 'title arguments' => array(1), - 'route_name' => 'user.view', - ); - $items['user/%user/cancel'] = array( - 'route_name' => 'user.cancel', - ); - $items['user/%user/cancel/confirm/%/%'] = array( - 'title' => 'Confirm account cancellation', - 'route_name' => 'user.cancel_confirm', - ); - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function user_menu_link_defaults() { diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index 1b28732..1ae2ef1 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -2382,21 +2382,6 @@ public function executeHookMenuLinkDefaults(array &$existing_links) { } /** - * If this display creates a page with a menu item, implement it here. - * - * @param array $callbacks - * An array of already existing menu items provided by drupal. - * - * @return array - * The menu router items registers for this display. - * - * @see hook_menu() - */ - public function executeHookMenu($callbacks) { - return array(); - } - - /** * Render this display. */ public function render() { diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 1959cd8..191f3e8 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -271,51 +271,6 @@ function views_permission() { } /** - * Implement hook_menu_alter(). - */ -function views_menu_alter(&$callbacks) { - $our_paths = array(); - $views = views_get_applicable_views('uses_hook_menu'); - foreach ($views as $data) { - list($view, $display_id) = $data; - $result = $view->executeHookMenu($display_id, $callbacks); - if (is_array($result)) { - // The menu system doesn't support having two otherwise - // identical paths with different placeholders. So we - // want to remove the existing items from the menu whose - // paths would conflict with ours. - - // First, we must find any existing menu items that may - // conflict. We use a regular expression because we don't - // know what placeholders they might use. Note that we - // first construct the regex itself by replacing %views_arg - // in the display path, then we use this constructed regex - // (which will be something like '#^(foo/%[^/]*/bar)$#') to - // search through the existing paths. - $regex = '#^(' . preg_replace('#%views_arg#', '%[^/]*', implode('|', array_keys($result))) . ')$#'; - $matches = preg_grep($regex, array_keys($callbacks)); - - // Remove any conflicting items that were found. - foreach ($matches as $path) { - // Don't remove the paths we just added! - if (!isset($our_paths[$path])) { - unset($callbacks[$path]); - } - } - foreach ($result as $path => $item) { - if (!isset($callbacks[$path])) { - // Add a new item, possibly replacing (and thus effectively - // overriding) one that we removed above. - $callbacks[$path] = $item; - } - $our_paths[$path] = TRUE; - } - } - $view->destroy(); - } -} - -/** * Implements hook_menu_link_defaults_alter(). */ function views_menu_link_defaults_alter(array &$links) { diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php index 2f1273c..01dceec 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php @@ -123,8 +123,9 @@ public function getForm(ViewStorageInterface $view, $display_id, $js) { // With the below logic, we may end up rendering a form twice (or two forms // each sharing the same element ids), potentially resulting in // _drupal_add_js() being called twice to add the same setting. drupal_get_js() - // is ok with that, but until ajax_render() is (http://drupal.org/node/208611), - // reset the _drupal_add_js() static before rendering the second time. + // is ok with that, but until \Drupal\Core\Ajax\AjaxResponse::ajaxRender() + // is (http://drupal.org/node/208611), reset the _drupal_add_js() static + // before rendering the second time. $drupal_add_js_original = _drupal_add_js(); $drupal_add_js = &drupal_static('_drupal_add_js'); $response = views_ajax_form_wrapper($form_state['form_id'], $form_state); diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module index 348372d..87f480e 100644 --- a/core/modules/views_ui/views_ui.module +++ b/core/modules/views_ui/views_ui.module @@ -38,29 +38,6 @@ function views_ui_help($path, $arg) { } /** - * Implements hook_menu(). - */ -function views_ui_menu() { - $items = array(); - - // Top-level Views module pages (not tied to a particular View). - $items['admin/structure/views'] = array( - 'title' => 'Views', - 'description' => 'Manage customized lists of content.', - 'route_name' => 'views_ui.list', - ); - - // A page in the Reports section to show usage of plugins in all views. - $items['admin/reports/views-plugins'] = array( - 'title' => 'Views plugins', - 'description' => 'Overview of plugins used in all views.', - 'route_name' => 'views_ui.reports_plugins', - ); - - return $items; -} - -/** * Implements hook_menu_link_defaults(). */ function views_ui_menu_link_defaults() {