當前位置: 首頁>>代碼示例>>PHP>>正文


PHP View::getExecutable方法代碼示例

本文整理匯總了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));
 }
開發者ID:ibonelli,項目名稱:DrupalConsole,代碼行數:27,代碼來源:DebugCommand.php

示例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();
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:51,代碼來源:WizardPluginBase.php


注:本文中的Drupal\views\Entity\View::getExecutable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。