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


PHP ViewExecutable::addHandler方法代碼示例

本文整理匯總了PHP中Drupal\views\ViewExecutable::addHandler方法的典型用法代碼示例。如果您正苦於以下問題:PHP ViewExecutable::addHandler方法的具體用法?PHP ViewExecutable::addHandler怎麽用?PHP ViewExecutable::addHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\views\ViewExecutable的用法示例。


在下文中一共展示了ViewExecutable::addHandler方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: submitItemAdd

 /**
  * Submit handler for adding new item(s) to a view.
  */
 public function submitItemAdd($form, FormStateInterface $form_state)
 {
     $type = $form_state->get('type');
     $types = ViewExecutable::getHandlerTypes();
     $section = $types[$type]['plural'];
     $display_id = $form_state->get('display_id');
     // Handle the override select.
     list($was_defaulted, $is_defaulted) = $this->getOverrideValues($form, $form_state);
     if ($was_defaulted && !$is_defaulted) {
         // We were using the default display's values, but we're now overriding
         // the default display and saving values specific to this display.
         $display =& $this->executable->displayHandlers->get($display_id);
         // setOverride toggles the override of this section.
         $display->setOverride($section);
     } elseif (!$was_defaulted && $is_defaulted) {
         // We used to have an override for this display, but the user now wants
         // to go back to the default display.
         // Overwrite the default display with the current form values, and make
         // the current display use the new default values.
         $display =& $this->executable->displayHandlers->get($display_id);
         // optionsOverride toggles the override of this section.
         $display->setOverride($section);
     }
     if (!$form_state->isValueEmpty('name') && is_array($form_state->getValue('name'))) {
         // Loop through each of the items that were checked and add them to the view.
         foreach (array_keys(array_filter($form_state->getValue('name'))) as $field) {
             list($table, $field) = explode('.', $field, 2);
             if ($cut = strpos($field, '$')) {
                 $field = substr($field, 0, $cut);
             }
             $id = $this->executable->addHandler($display_id, $type, $table, $field);
             // check to see if we have group by settings
             $key = $type;
             // Footer,header and empty text have a different internal handler type(area).
             if (isset($types[$type]['type'])) {
                 $key = $types[$type]['type'];
             }
             $item = array('table' => $table, 'field' => $field);
             $handler = Views::handlerManager($key)->getHandler($item);
             if ($this->executable->displayHandlers->get('default')->useGroupBy() && $handler->usesGroupBy()) {
                 $this->addFormToStack('handler-group', $display_id, $type, $id);
             }
             // check to see if this type has settings, if so add the settings form first
             if ($handler && $handler->hasExtraOptions()) {
                 $this->addFormToStack('handler-extra', $display_id, $type, $id);
             }
             // Then add the form to the stack
             $this->addFormToStack('handler', $display_id, $type, $id);
         }
     }
     if (isset($this->form_cache)) {
         unset($this->form_cache);
     }
     // Store in cache
     $this->cacheSet();
 }
開發者ID:anyforsoft,項目名稱:csua_d8,代碼行數:59,代碼來源:ViewUI.php


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