diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php index bdcb31b..d747283 100644 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@ -238,7 +238,10 @@ public function cacheStart() { } /** - * Gather the JS/CSS from the render array, the html head from the band data. + * Gather the JS/CSS from the render array and the html head from band data. + * + * @param array $render_array + * The view render array to collect data from. */ protected function gatherHeaders(array $render_array = []) { // Simple replacement for head diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 5e9965a..02fffa3 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -426,7 +426,7 @@ public function usesAreas() { * @param string $display_id * The display to attach to. * @param array $build - * The main view render array + * The parent view render array. */ public function attachTo(ViewExecutable $view, $display_id, array &$build) { } @@ -2138,6 +2138,8 @@ public function render() { $element = array( '#theme' => $this->themeFunctions(), '#view' => $this->view, + // Assigned by reference so anything added in $element['#attached'] will + // be available on the view. '#attached' => &$this->view->element['#attached'], '#pre_render' => [[$this, 'elementPreRender']], '#rows' => $rows, @@ -2147,19 +2149,21 @@ public function render() { } /** - * Pre render callback for view display rendering. + * #pre_render callback for view display rendering. * * @see self::render() * * @param array $element + * The element to #pre_render * * @return array + * The processed element. */ - public function elementPreRender($element) { + public function elementPreRender(array $element) { $view = $element['#view']; $empty = empty($view->result); - // Force a render array so CSS/JS can be added. + // Force a render array so CSS/JS can be attached. if (!is_array($element['#rows'])) { $element['#rows'] = array('#markup' => $element['#rows']); } diff --git a/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php b/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php index e03be68..72516cf 100644 --- a/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/field/CounterTest.php @@ -86,8 +86,8 @@ protected function setUp() { $this->view->display_handler = $this->display; $this->view->pager = $this->pager; - foreach (ViewTestData::dataSet() as $count => $set) { - $this->testData[] = new ResultRow($set + ['index' => $count]); + foreach (ViewTestData::dataSet() as $index => $set) { + $this->testData[] = new ResultRow($set + ['index' => $index]); } $this->definition = array('title' => 'counter field', 'plugin_type' => 'field');