core/lib/Drupal/Core/Controller/AjaxController.php | 2 +- .../Drupal/Core/Controller/DialogController.php | 4 ++-- core/lib/Drupal/Core/Controller/HtmlController.php | 6 +++--- .../Core/Controller/MainContentControllerBase.php | 6 +++--- .../Controller/MainContentControllerInterface.php | 18 ++++++++-------- .../lib/Drupal/Core/Controller/ModalController.php | 2 +- core/modules/system/theme.api.php | 25 +++++++++++----------- .../Tests/Core/Controller/AjaxControllerTest.php | 4 ++-- 8 files changed, 34 insertions(+), 33 deletions(-) diff --git a/core/lib/Drupal/Core/Controller/AjaxController.php b/core/lib/Drupal/Core/Controller/AjaxController.php index 641a16a..0dda746 100644 --- a/core/lib/Drupal/Core/Controller/AjaxController.php +++ b/core/lib/Drupal/Core/Controller/AjaxController.php @@ -41,7 +41,7 @@ public function __construct(ControllerResolverInterface $controller_resolver, El /** * {@inheritdoc} */ - public function renderMainContent(array $main_content, $title, array $custom) { + public function renderContentIntoResponse(array $main_content, $title, array $custom) { $response = new AjaxResponse(); if (isset($main_content['#type']) && ($main_content['#type'] == 'ajax')) { diff --git a/core/lib/Drupal/Core/Controller/DialogController.php b/core/lib/Drupal/Core/Controller/DialogController.php index c5f3a40..655354d 100644 --- a/core/lib/Drupal/Core/Controller/DialogController.php +++ b/core/lib/Drupal/Core/Controller/DialogController.php @@ -40,7 +40,7 @@ public function __construct(ControllerResolverInterface $controller_resolver, Ti /** * {@inheritdoc} */ - public function prepareMainContent(array $main_content, Request $request, RouteMatchInterface $route_match) { + public function prepareContent(array $main_content, Request $request, RouteMatchInterface $route_match) { // Determine the dialog options and the target for the OpenDialogCommand. $options = $request->request->get('dialogOptions', array()); // Generate the target wrapper for the dialog. @@ -73,7 +73,7 @@ public function prepareMainContent(array $main_content, Request $request, RouteM /** * {@inheritdoc} */ - public function renderMainContent(array $main_content, $title, array $custom) { + public function renderContentIntoResponse(array $main_content, $title, array $custom) { $content = drupal_render_root($main_content); drupal_process_attached($main_content); diff --git a/core/lib/Drupal/Core/Controller/HtmlController.php b/core/lib/Drupal/Core/Controller/HtmlController.php index 5171635..79bce4a 100644 --- a/core/lib/Drupal/Core/Controller/HtmlController.php +++ b/core/lib/Drupal/Core/Controller/HtmlController.php @@ -69,7 +69,7 @@ public function __construct(ControllerResolverInterface $controller_resolver, Ti * * The HTML body: wraps the main content in #type 'page'. */ - public function prepareMainContent(array $main_content, Request $request, RouteMatchInterface $route_match) { + public function prepareContent(array $main_content, Request $request, RouteMatchInterface $route_match) { // If the _content result already is #type => page, we have no work to do: // the "main content" already is an entire "page" (see html.html.twig). if (isset($main_content['#type']) && $main_content['#type'] === 'page') { @@ -88,7 +88,7 @@ public function prepareMainContent(array $main_content, Request $request, RouteM // title. We set its $is_root_call parameter to FALSE, to ensure // #post_render_cache callbacks are not yet applied. This is essentially // "pre-rendering" the main content, the "full rendering" will happen in - // ::renderMainContent(). + // ::renderContentIntoResponse(). // @todo Remove this once https://www.drupal.org/node/2359901 lands. if (!empty($main_content)) { drupal_render($main_content, FALSE); @@ -147,7 +147,7 @@ public function prepareMainContent(array $main_content, Request $request, RouteM * * The entire HTML: takes a #type 'page' and wraps it in a #type 'html'. */ - public function renderMainContent(array $page, $title, array $custom) { + public function renderContentIntoResponse(array $page, $title, array $custom) { if (!isset($page['#type']) || $page['#type'] !== 'page') { throw new \LogicException('Must be #type page'); } diff --git a/core/lib/Drupal/Core/Controller/MainContentControllerBase.php b/core/lib/Drupal/Core/Controller/MainContentControllerBase.php index 0adcf05..64517fc 100644 --- a/core/lib/Drupal/Core/Controller/MainContentControllerBase.php +++ b/core/lib/Drupal/Core/Controller/MainContentControllerBase.php @@ -52,7 +52,7 @@ public function getMainContent(Request $request, $controller_definition) { /** * {@inheritdoc} */ - public function prepareMainContent(array $main_content, Request $request, RouteMatchInterface $route_match) { + public function prepareContent(array $main_content, Request $request, RouteMatchInterface $route_match) { // In this default implementation: return [ // We return $main_content verbatim. @@ -80,8 +80,8 @@ public function handle(Request $request, RouteMatchInterface $route_match, $_con throw new \LogicException('Invalid render array returned by ' . $_content . '.'); } - list($main_content, $title, $custom) = $this->prepareMainContent($main_content, $request, $route_match); - return $this->renderMainContent($main_content, $title, $custom); + list($content, $title, $custom) = $this->prepareContent($main_content, $request, $route_match); + return $this->renderContentIntoResponse($content, $title, $custom); } } diff --git a/core/lib/Drupal/Core/Controller/MainContentControllerInterface.php b/core/lib/Drupal/Core/Controller/MainContentControllerInterface.php index 304dd16..02859f5 100644 --- a/core/lib/Drupal/Core/Controller/MainContentControllerInterface.php +++ b/core/lib/Drupal/Core/Controller/MainContentControllerInterface.php @@ -21,8 +21,8 @@ * The three steps of handling a request for a main content controller are part * of the interface: * 1. getMainContent(): get the main content from the (_content) sub-controller - * 2. prepareMainContent(): apply any preparations/transformations - * 3. renderMainContent(): turn the main content render array into a response + * 2. prepareContent(): apply any preparations/transformations + * 3. renderContentIntoResponse(): turn the content render array into a response */ interface MainContentControllerInterface { @@ -42,7 +42,7 @@ public function getMainContent(Request $request, $controller_definition); /** - * Prepare the main content render array. + * Given the main content, prepare the "actual content" render array. * * @param array $main_content * The render array representing the main content. @@ -53,17 +53,17 @@ public function getMainContent(Request $request, $controller_definition); * * @return array * An array with three values: - * 0. The prepared render array representing the main content. + * 0. The prepared render array representing the (actual) content. * 1. The title. * 2. Key-value pairs with custom options for this main content controller. */ - public function prepareMainContent(array $main_content, Request $request, RouteMatchInterface $route_match); + public function prepareContent(array $main_content, Request $request, RouteMatchInterface $route_match); /** - * Renders the main content array into a response. + * Renders the content array into a response. * - * @param array $main_content - * The render array representing the main content. + * @param array $content + * The render array representing the content. * @param string|NULL $title * The title of the main content, if any. * @param array $custom @@ -72,7 +72,7 @@ public function prepareMainContent(array $main_content, Request $request, RouteM * @return \Symfony\Component\HttpFoundation\Response * The Response in the format that this implementation supports. */ - public function renderMainContent(array $main_content, $title, array $custom); + public function renderContentIntoResponse(array $content, $title, array $custom); /** * Gets the main content render array and renders it into a response. diff --git a/core/lib/Drupal/Core/Controller/ModalController.php b/core/lib/Drupal/Core/Controller/ModalController.php index 9303fa6..ed1adbd 100644 --- a/core/lib/Drupal/Core/Controller/ModalController.php +++ b/core/lib/Drupal/Core/Controller/ModalController.php @@ -18,7 +18,7 @@ class ModalController extends DialogController { /** * {@inheritdoc} */ - public function renderMainContent(array $main_content, $title, array $custom) { + public function renderContentIntoResponse(array $main_content, $title, array $custom) { $content = drupal_render_root($main_content); drupal_process_attached($main_content); diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index 5729718..bd52ba9 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -325,8 +325,8 @@ * content controllers: * 1. getMainContent(): get the main content from the (_content) sub-controller, * this must always be a render array - * 2. prepareMainContent(): apply any preparations/transformations - * 3. renderMainContent(): turn the main content render array into a response + * 2. prepareContent(): apply any preparations/transformations + * 3. renderContentIntoResponse(): turn the content render array into a response * * These same steps are applied regardless of which main content controller is * selected: it's the same for the AJAX, HTML, Drupal Dialog and Drupal Modal @@ -337,9 +337,9 @@ * example. And since rendering HTML pages is the most common use for Drupal, * this will cover that also. * - * \Drupal\Core\Controller\HtmlController::prepareMainContent() looks at the - * render array it receives. If it's already #type 'page', then most of the work - * it should do is already done. After all, if a #type 'page' is indicated to be + * \Drupal\Core\Controller\HtmlController::prepareContent() looks at the render + * array it receives. If it's already #type 'page', then most of the work it + * should do is already done. After all, if a #type 'page' is indicated to be * the main content, then that implies no decorations should be applied, since * it already represents the final for the HTML document. * If it's not yet #type 'page', however, then we need to build that still. The @@ -348,13 +348,14 @@ * any decorating. But when Block module is enabled, BlockPageVariant is used, * which allows the site builder to place blocks in any of the page regions, and * hence "decorate" the main content. - * The outcome of \Drupal\Core\Controller\HtmlController::prepareMainContent() - * is always a #type 'page' render array. - * - * \Drupal\Core\Controller\HtmlController::renderMainContent() — the third and - * final step — then wraps the #type 'page' (which represents page.html.twig) in - * a #type 'html' render array (which represents html.html.twig), to then render - * the entire HTML document. + * The outcome of \Drupal\Core\Controller\HtmlController::prepareContent() is + * always a #type 'page' render array. This is considered the "actual" content + * for HTML responses. + * + * \Drupal\Core\Controller\HtmlController::renderContentIntoResponse() — the + * third and final step — then wraps the #type 'page' (which represents + * page.html.twig) in a #type 'html' render array (which represents + * html.html.twig), to then render the entire HTML document. * * For HTML pages to be rendered in limited environments, such as when you are * installing or updating Drupal, or when you put it in maintenance mode, or diff --git a/core/tests/Drupal/Tests/Core/Controller/AjaxControllerTest.php b/core/tests/Drupal/Tests/Core/Controller/AjaxControllerTest.php index 0382853..de8f094 100644 --- a/core/tests/Drupal/Tests/Core/Controller/AjaxControllerTest.php +++ b/core/tests/Drupal/Tests/Core/Controller/AjaxControllerTest.php @@ -49,12 +49,12 @@ protected function setUp() { /** * Tests the renderMainContent method. * - * @covers \Drupal\Core\Controller\AjaxController::renderMainContent + * @covers \Drupal\Core\Controller\AjaxController::renderContentIntoResponse */ public function testRenderWithFragmentObject() { $main_content = ['#markup' => 'example content']; /** @var \Drupal\Core\Ajax\AjaxResponse $result */ - $result = $this->ajaxController->renderMainContent($main_content, '', []); + $result = $this->ajaxController->renderContentIntoResponse($main_content, '', []); $this->assertInstanceOf('Drupal\Core\Ajax\AjaxResponse', $result);