/** * {@inheritdoc} */ public function renderMoreLink() { if ($this->isMoreEnabled() && ($this->useMoreAlways() || !empty($this->view->pager) && $this->view->pager->hasMoreRecords())) { // If the user has supplied a custom "More" link path, replace any // argument tokens and use that for the URL. if ($this->getOption('link_display') == 'custom_url' && ($override_path = $this->getOption('link_url'))) { $tokens = $this->getArgumentsTokens(); $path = $this->viewsTokenReplace($override_path, $tokens); // @todo Views should expect and store a leading /. See: // https://www.drupal.org/node/2423913 $url = Url::fromUserInput('/' . $path); } else { $url = $this->view->getUrl(NULL, $this->display['id']); } // If a URL is available (either from the display or a custom path), // render the "More" link. if ($url) { $url_options = array(); if (!empty($this->view->exposed_raw_input)) { $url_options['query'] = $this->view->exposed_raw_input; } $url->setOptions($url_options); $theme = $this->view->buildThemeFunctions('views_more'); return array('#theme' => $theme, '#more_url' => $url->toString(), '#link_text' => String::checkPlain($this->useMoreText()), '#view' => $this->view); } } }
/** * Tests the buildThemeFunctions() method. */ public function testBuildThemeFunctions() { $config = array('id' => 'test_view', 'tag' => 'OnE, TWO, and three', 'display' => array('default' => array('id' => 'default', 'display_plugin' => 'default', 'display_title' => 'Default'))); $storage = new View($config, 'view'); $user = $this->getMock('Drupal\\Core\\Session\\AccountInterface'); $view = new ViewExecutable($storage, $user); $expected = array('test_hook__test_view', 'test_hook'); $this->assertEquals($expected, $view->buildThemeFunctions('test_hook')); // Add a mock display. $display = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')->disableOriginalConstructor()->getMock(); $display->display = $config['display']['default']; $view->display_handler = $display; $expected = array('test_hook__test_view__default', 'test_hook__default', 'test_hook__one', 'test_hook__two', 'test_hook__and_three', 'test_hook__test_view', 'test_hook'); $this->assertEquals($expected, $view->buildThemeFunctions('test_hook')); //Change the name of the display plugin and make sure that is in the array. $view->display_handler->display['display_plugin'] = 'default2'; $expected = array('test_hook__test_view__default', 'test_hook__default', 'test_hook__one', 'test_hook__two', 'test_hook__and_three', 'test_hook__test_view__default2', 'test_hook__default2', 'test_hook__test_view', 'test_hook'); $this->assertEquals($expected, $view->buildThemeFunctions('test_hook')); }
/** * Render the 'more' link */ public function renderMoreLink() { if ($this->isMoreEnabled() && ($this->useMoreAlways() || !empty($this->view->pager) && $this->view->pager->hasMoreRecords())) { $path = $this->getPath(); if ($this->getOption('link_display') == 'custom_url' && ($override_path = $this->getOption('link_url'))) { $tokens = $this->getArgumentsTokens(); $path = strtr($override_path, $tokens); } if ($path) { if (empty($override_path)) { $path = $this->view->getUrl(NULL, $path); } $url_options = array(); if (!empty($this->view->exposed_raw_input)) { $url_options['query'] = $this->view->exposed_raw_input; } $theme = $this->view->buildThemeFunctions('views_more'); $path = check_url(url($path, $url_options)); return array('#theme' => $theme, '#more_url' => $path, '#link_text' => String::checkPlain($this->useMoreText()), '#view' => $this->view); } } }
/** * {@inheritdoc} */ public function themeFunctions() { return $this->view->buildThemeFunctions($this->definition['theme']); }