当前位置: 首页>>代码示例>>PHP>>正文


PHP ViewExecutable::id方法代码示例

本文整理汇总了PHP中Drupal\views\ViewExecutable::id方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewExecutable::id方法的具体用法?PHP ViewExecutable::id怎么用?PHP ViewExecutable::id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\views\ViewExecutable的用法示例。


在下文中一共展示了ViewExecutable::id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hook_views_query_alter

/**
 * Alter the query before it is executed.
 *
 * @param \Drupal\views\ViewExecutable $view
 *   The view object about to be processed.
 * @param QueryPluginBase $query
 *   The query plugin object for the query.
 *
 * @see hook_views_query_substitutions()
 * @see \Drupal\views\Plugin\views\query\Sql
 */
function hook_views_query_alter(ViewExecutable $view, QueryPluginBase $query)
{
    // (Example assuming a view with an exposed filter on node title.)
    // If the input for the title filter is a positive integer, filter against
    // node ID instead of node title.
    if ($view->id() == 'my_view' && is_numeric($view->exposed_raw_input['title']) && $view->exposed_raw_input['title'] > 0) {
        // Traverse through the 'where' part of the query.
        foreach ($query->where as &$condition_group) {
            foreach ($condition_group['conditions'] as &$condition) {
                // If this is the part of the query filtering on title, chang the
                // condition to filter on node ID.
                if ($condition['field'] == 'node.title') {
                    $condition = array('field' => 'node.nid', 'value' => $view->exposed_raw_input['title'], 'operator' => '=');
                }
            }
        }
    }
}
开发者ID:sarahwillem,项目名称:OD8,代码行数:29,代码来源:views.api.php

示例2: assertViewsCacheTagsFromStaticRenderArray

 /**
  * Asserts a view's result & render cache items' cache tags.
  *
  * This method starts with a pre bubbling basic render array.
  *
  * @param \Drupal\views\ViewExecutable $view
  *   The view.
  * @param string[] $expected_render_array_cache_tags
  *   The expected render cache tags.
  * @param bool $views_caching_is_enabled
  *   Defines whether views output / render caching is enabled.
  *
  * @return array
  *   The render array.
  */
 protected function assertViewsCacheTagsFromStaticRenderArray(ViewExecutable $view, array $expected_render_array_cache_tags, $views_caching_is_enabled)
 {
     $original = $build = DisplayPluginBase::buildBasicRenderable($view->id(), $view->current_display ?: 'default', $view->args);
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = \Drupal::service('renderer');
     /** @var \Drupal\Core\Render\RenderCacheInterface $render_cache */
     $render_cache = \Drupal::service('render_cache');
     // Ensure the current request is a GET request so that render caching is
     // active for direct rendering of views, just like for actual requests.
     /** @var \Symfony\Component\HttpFoundation\RequestStack $request_stack */
     $request_stack = \Drupal::service('request_stack');
     $request = new Request();
     $request->server->set('REQUEST_TIME', REQUEST_TIME);
     $request_stack->push($request);
     $renderer->renderRoot($build);
     // Render array cache tags.
     $this->pass('Checking render array cache tags.');
     sort($expected_render_array_cache_tags);
     $this->assertEqual($build['#cache']['tags'], $expected_render_array_cache_tags);
     $this->debugCacheTags($build['#cache']['tags'], $expected_render_array_cache_tags);
     $this->pass('Checking Views render cache item cache tags.');
     $original['#cache'] += ['contexts' => []];
     $original['#cache']['contexts'] = Cache::mergeContexts($original['#cache']['contexts'], $this->container->getParameter('renderer.config')['required_cache_contexts']);
     $render_cache_item = $render_cache->get($original);
     if ($views_caching_is_enabled) {
         $this->assertTrue(!empty($render_cache_item), 'Render cache item found.');
         if ($render_cache_item) {
             $this->assertEqual($render_cache_item['#cache']['tags'], $expected_render_array_cache_tags);
             $this->debugCacheTags($render_cache_item['#cache']['tags'], $expected_render_array_cache_tags);
         }
     } else {
         $this->assertFalse($render_cache_item, 'Render cache item not found.');
     }
     return $build;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:50,代码来源:AssertViewsCacheTagsTrait.php

示例3: getViewsURL

 /**
  * Get the Url object to link to a View display with given arguments.
  *
  * @param \Drupal\views\ViewExecutable $view
  * @param $display_id
  * @param array $args
  *
  * @return \Drupal\Core\Url
  */
 static function getViewsURL(ViewExecutable $view, $display_id, $args = [])
 {
     $route_parameters = static::getViewRouteParameters($args);
     $route_name = static::getDisplayRouteName($view->id(), $display_id);
     return Url::fromRoute($route_name, $route_parameters);
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:15,代码来源:CalendarHelper.php


注:本文中的Drupal\views\ViewExecutable::id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。