本文整理汇总了PHP中Drupal\views\Entity\View::getExecutable方法的典型用法代码示例。如果您正苦于以下问题:PHP View::getExecutable方法的具体用法?PHP View::getExecutable怎么用?PHP View::getExecutable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\Entity\View
的用法示例。
在下文中一共展示了View::getExecutable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewDisplayPaths
/**
* @param \Drupal\views\Entity\View $view
* @param null $display_id
* @return string
*/
protected function viewDisplayPaths(View $view, $display_id = null)
{
$all_paths = array();
$executable = $view->getExecutable();
$executable->initDisplay();
foreach ($executable->displayHandlers as $display) {
if ($display->hasPath()) {
$path = $display->getPath();
if (strpos($path, '%') === false) {
// @see Views should expect and store a leading /. See:
// https://www.drupal.org/node/2423913
$all_paths[] = '/' . $path;
} else {
$all_paths[] = '/' . $path;
}
if ($display_id !== null && $display_id == $display->getBaseId()) {
return '/' . $path;
}
}
}
return implode(', ', array_unique($all_paths));
}
示例2: addDisplays
/**
* Adds the array of display options to the view, with appropriate overrides.
*/
protected function addDisplays(View $view, $display_options, $form, FormStateInterface $form_state)
{
// Initialize and store the view executable to get the display plugin
// instances.
$executable = $view->getExecutable();
// Display: Master
$default_display = $executable->newDisplay('default', 'Master', 'default');
foreach ($display_options['default'] as $option => $value) {
$default_display->setOption($option, $value);
}
// Display: Page
if (isset($display_options['page'])) {
$display = $executable->newDisplay('page', 'Page', 'page_1');
// The page display is usually the main one (from the user's point of
// view). Its options should therefore become the overall view defaults,
// so that new displays which are added later automatically inherit them.
$this->setDefaultOptions($display_options['page'], $display, $default_display);
// Display: Feed (attached to the page).
if (isset($display_options['feed'])) {
$display = $executable->newDisplay('feed', 'Feed', 'feed_1');
$this->setOverrideOptions($display_options['feed'], $display, $default_display);
}
}
// Display: Block.
if (isset($display_options['block'])) {
$display = $executable->newDisplay('block', 'Block', 'block_1');
// When there is no page, the block display options should become the
// overall view defaults.
if (!isset($display_options['page'])) {
$this->setDefaultOptions($display_options['block'], $display, $default_display);
} else {
$this->setOverrideOptions($display_options['block'], $display, $default_display);
}
}
// Display: REST export.
if (isset($display_options['rest_export'])) {
$display = $executable->newDisplay('rest_export', 'REST export', 'rest_export_1');
// If there is no page or block, the REST export display options should
// become the overall view defaults.
if (!isset($display_options['page']) && !isset($display_options['block'])) {
$this->setDefaultOptions($display_options['rest_export'], $display, $default_display);
} else {
$this->setOverrideOptions($display_options['rest_export'], $display, $default_display);
}
}
// Initialize displays and merge all plugin default values.
$executable->mergeDefaults();
}