本文整理汇总了PHP中Drupal\views\ViewExecutable::initPager方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewExecutable::initPager方法的具体用法?PHP ViewExecutable::initPager怎么用?PHP ViewExecutable::initPager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\ViewExecutable
的用法示例。
在下文中一共展示了ViewExecutable::initPager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
/**
* Builds the necessary info to execute the query.
*/
public function build(ViewExecutable $view) {
// Make the query distinct if the option was set.
if (!empty($this->options['distinct'])) {
$this->setDistinct(TRUE);
}
// Store the view in the object to be able to use it later.
$this->view = $view;
$view->initPager();
// Let the pager modify the query to add limits.
$view->pager->query();
$view->build_info['query'] = $this->query();
$view->build_info['count_query'] = $this->query(TRUE);
}
示例2: build
/**
* {@inheritdoc}
*/
public function build(ViewExecutable $view)
{
$this->view = $view;
if ($this->shouldAbort()) {
return;
}
// Setup the nested filter structure for this query.
if (!empty($this->conditions)) {
// If the different groups are combined with the OR operator, we have to
// add a new OR filter to the query to which the filters for the groups
// will be added.
if ($this->group_operator === 'OR') {
$base = $this->query->createConditionGroup('OR');
$this->query->addConditionGroup($base);
} else {
$base = $this->query;
}
// Add a nested filter for each filter group, with its set conjunction.
foreach ($this->conditions as $group_id => $group) {
if (!empty($group['conditions']) || !empty($group['condition_groups'])) {
$group += array('type' => 'AND');
// For filters without a group, we want to always add them directly to
// the query.
$conditions = $group_id === '' ? $this->query : $this->query->createConditionGroup($group['type']);
if (!empty($group['conditions'])) {
foreach ($group['conditions'] as $condition) {
list($field, $value, $operator) = $condition;
$conditions->addCondition($field, $value, $operator);
}
}
if (!empty($group['condition_groups'])) {
foreach ($group['condition_groups'] as $nested_conditions) {
$conditions->addConditionGroup($nested_conditions);
}
}
// If no group was given, the filters were already set on the query.
if ($group_id !== '') {
$base->addConditionGroup($conditions);
}
}
}
}
// Initialize the pager and let it modify the query to add limits.
$view->initPager();
$view->pager->query();
// Set the search ID, if it was not already set.
if ($this->query->getOption('search id') == get_class($this->query)) {
$this->query->setOption('search id', 'search_api_views:' . $view->storage->id() . ':' . $view->current_display);
}
// Add the "search_api_bypass_access" option to the query, if desired.
if (!empty($this->options['bypass_access'])) {
$this->query->setOption('search_api_bypass_access', TRUE);
}
// If the View and the Panel conspire to provide an overridden path then
// pass that through as the base path.
if (($path = $this->view->getPath()) && strpos(Url::fromRoute('<current>')->toString(), $this->view->override_path) !== 0) {
$this->query->setOption('search_api_base_path', $path);
}
}