本文整理汇总了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();
}