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


PHP ViewExecutable::initQuery方法代码示例

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


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

示例1: assertGrid

 /**
  * Generates a grid and asserts that it is displaying correctly.
  *
  * @param \Drupal\views\ViewExecutable $view
  *   The executable to prepare.
  * @param string $alignment
  *   The alignment of the grid to test.
  * @param int $columns
  *   The number of columns in the grid to test.
  */
 protected function assertGrid(ViewExecutable $view, $alignment, $columns)
 {
     $view->setDisplay('default');
     $view->initStyle();
     $view->initHandlers();
     $view->initQuery();
     $view->style_plugin->options['alignment'] = $alignment;
     $view->style_plugin->options['columns'] = $columns;
     $this->executeView($view);
     $output = $view->preview();
     $output = drupal_render($output);
     $this->setRawContent($output);
     if (!in_array($alignment, $this->alignmentsTested)) {
         $result = $this->xpath('//div[contains(@class, "views-view-grid") and contains(@class, :alignment) and contains(@class, :columns)]', array(':alignment' => $alignment, ':columns' => 'cols-' . $columns));
         $this->assertTrue(count($result), ucfirst($alignment) . " grid markup detected.");
         $this->alignmentsTested[] = $alignment;
     }
     $width = '0';
     switch ($columns) {
         case 5:
             $width = '20';
             break;
         case 4:
             $width = '25';
             break;
         case 3:
             $width = '33.3333';
             break;
         case 2:
             $width = '50';
             break;
         case 1:
             $width = '100';
             break;
     }
     // Ensure last column exists.
     $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns) and starts-with(@style, :width)]', array(':columns' => 'col-' . $columns, ':width' => 'width: ' . $width));
     $this->assertTrue(count($result), ucfirst($alignment) . " {$columns} column grid: last column exists and automatic width calculated correctly.");
     // Ensure no extra columns were generated.
     $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns)]', array(':columns' => 'col-' . ($columns + 1)));
     $this->assertFalse(count($result), ucfirst($alignment) . " {$columns} column grid: no extraneous columns exist.");
     // Ensure tokens are being replaced in custom row/column classes.
     $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, "name-John")]');
     $this->assertTrue(count($result), ucfirst($alignment) . " {$columns} column grid: Token replacement verified in custom column classes.");
     $result = $this->xpath('//div[contains(@class, "views-row") and contains(@class, "age-25")]');
     $this->assertTrue(count($result), ucfirst($alignment) . " {$columns} column grid: Token replacement verified in custom row classes.");
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:57,代码来源:StyleGridTest.php

示例2: buildOptionsForm


//.........这里部分代码省略.........
                 $form['markup'] = array('#prefix' => '<div class="js-form-item form-item description">', '#markup' => $this->t('You may also adjust the @settings for the currently selected access restriction.', array('@settings' => $this->optionLink($this->t('settings'), 'access_options'))), '#suffix' => '</div>');
             }
             break;
         case 'access_options':
             $plugin = $this->getPlugin('access');
             $form['#title'] .= $this->t('Access options');
             if ($plugin) {
                 $form['access_options'] = array('#tree' => TRUE);
                 $plugin->buildOptionsForm($form['access_options'], $form_state);
             }
             break;
         case 'cache':
             $form['#title'] .= $this->t('Caching');
             $form['cache'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
             $cache = $this->getOption('cache');
             $form['cache']['type'] = array('#title' => $this->t('Caching'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('cache', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $cache['type']);
             $cache_plugin = $this->getPlugin('cache');
             if ($cache_plugin->usesOptions()) {
                 $form['markup'] = array('#prefix' => '<div class="js-form-item form-item description">', '#suffix' => '</div>', '#markup' => $this->t('You may also adjust the @settings for the currently selected cache mechanism.', array('@settings' => $this->optionLink($this->t('settings'), 'cache_options'))));
             }
             break;
         case 'cache_options':
             $plugin = $this->getPlugin('cache');
             $form['#title'] .= $this->t('Caching options');
             if ($plugin) {
                 $form['cache_options'] = array('#tree' => TRUE);
                 $plugin->buildOptionsForm($form['cache_options'], $form_state);
             }
             break;
         case 'query':
             $query_options = $this->getOption('query');
             $plugin_name = $query_options['type'];
             $form['#title'] .= $this->t('Query options');
             $this->view->initQuery();
             if ($this->view->query) {
                 $form['query'] = array('#tree' => TRUE, 'type' => array('#type' => 'value', '#value' => $plugin_name), 'options' => array('#tree' => TRUE));
                 $this->view->query->buildOptionsForm($form['query']['options'], $form_state);
             }
             break;
         case 'rendering_language':
             $form['#title'] .= $this->t('Rendering language');
             if (\Drupal::languageManager()->isMultilingual() && $this->isBaseTableTranslatable()) {
                 $options = $this->buildRenderingLanguageOptions();
                 $form['rendering_language'] = array('#type' => 'select', '#options' => $options, '#title' => $this->t('Rendering language'), '#description' => $this->t('All content that supports translations will be displayed in the selected language.'), '#default_value' => $this->getOption('rendering_language'));
             } else {
                 $form['rendering_language']['#markup'] = $this->t('The view is not based on a translatable entity type or the site is not multilingual.');
             }
             break;
         case 'style':
             $form['#title'] .= $this->t('How should this view be styled');
             $style_plugin = $this->getPlugin('style');
             $form['style'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
             $form['style']['type'] = array('#title' => $this->t('Style'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('style', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $style_plugin->definition['id'], '#description' => $this->t('If the style you choose has settings, be sure to click the settings button that will appear next to it in the View summary.'));
             if ($style_plugin->usesOptions()) {
                 $form['markup'] = array('#prefix' => '<div class="js-form-item form-item description">', '#suffix' => '</div>', '#markup' => $this->t('You may also adjust the @settings for the currently selected style.', array('@settings' => $this->optionLink($this->t('settings'), 'style_options'))));
             }
             break;
         case 'style_options':
             $form['#title'] .= $this->t('Style options');
             $style = TRUE;
             $style_plugin = $this->getOption('style');
             $name = $style_plugin['type'];
         case 'row_options':
             if (!isset($name)) {
                 $row_plugin = $this->getOption('row');
                 $name = $row_plugin['type'];
开发者ID:318io,项目名称:318-io,代码行数:67,代码来源:DisplayPluginBase.php

示例3: buildOptionsForm


//.........这里部分代码省略.........
                 $form['markup'] = array('#prefix' => '<div class="form-item description">', '#markup' => t('You may also adjust the !settings for the currently selected access restriction.', array('!settings' => $this->optionLink(t('settings'), 'access_options'))), '#suffix' => '</div>');
             }
             break;
         case 'access_options':
             $plugin = $this->getPlugin('access');
             $form['#title'] .= t('Access options');
             if ($plugin) {
                 $form['access_options'] = array('#tree' => TRUE);
                 $plugin->buildOptionsForm($form['access_options'], $form_state);
             }
             break;
         case 'cache':
             $form['#title'] .= t('Caching');
             $form['cache'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
             $cache = $this->getOption('cache');
             $form['cache']['type'] = array('#title' => t('Caching'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('cache', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $cache['type']);
             $cache_plugin = $this->getPlugin('cache');
             if ($cache_plugin->usesOptions()) {
                 $form['markup'] = array('#prefix' => '<div class="form-item description">', '#suffix' => '</div>', '#markup' => t('You may also adjust the !settings for the currently selected cache mechanism.', array('!settings' => $this->optionLink(t('settings'), 'cache_options'))));
             }
             break;
         case 'cache_options':
             $plugin = $this->getPlugin('cache');
             $form['#title'] .= t('Caching options');
             if ($plugin) {
                 $form['cache_options'] = array('#tree' => TRUE);
                 $plugin->buildOptionsForm($form['cache_options'], $form_state);
             }
             break;
         case 'query':
             $query_options = $this->getOption('query');
             $plugin_name = $query_options['type'];
             $form['#title'] .= t('Query options');
             $this->view->initQuery();
             if ($this->view->query) {
                 $form['query'] = array('#tree' => TRUE, 'type' => array('#type' => 'value', '#value' => $plugin_name), 'options' => array('#tree' => TRUE));
                 $this->view->query->buildOptionsForm($form['query']['options'], $form_state);
             }
             break;
         case 'field_langcode':
             $form['#title'] .= t('Field Language');
             $translatable_entity_tables = array();
             foreach (\Drupal::entityManager()->getDefinitions() as $entity_type) {
                 if ($entity_type->isTranslatable() && ($base_table = $entity_type->getBaseTable())) {
                     $translatable_entity_tables[] = $base_table;
                 }
             }
             // Doesn't make sense to show a field setting here if we aren't querying
             // an entity base table. Also, we make sure that there's at least one
             // entity type with a translation handler attached.
             if (in_array($this->view->storage->get('base_table'), $translatable_entity_tables)) {
                 $languages = array('***CURRENT_LANGUAGE***' => t("Current user's language"), '***DEFAULT_LANGUAGE***' => t("Default site language"), LanguageInterface::LANGCODE_NOT_SPECIFIED => t('Language neutral'));
                 $languages = array_merge($languages, views_language_list());
                 $form['field_langcode'] = array('#type' => 'select', '#title' => t('Field Language'), '#description' => t('All fields which support translations will be displayed in the selected language.'), '#options' => $languages, '#default_value' => $this->getOption('field_langcode'));
                 $form['field_langcode_add_to_query'] = array('#type' => 'checkbox', '#title' => t('When needed, add the field language condition to the query'), '#default_value' => $this->getOption('field_langcode_add_to_query'));
             } else {
                 $form['field_language']['#markup'] = t("You don't have translatable entity types.");
             }
             break;
         case 'style':
             $form['#title'] .= t('How should this view be styled');
             $style_plugin = $this->getPlugin('style');
             $form['style'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
             $form['style']['type'] = array('#title' => t('Style'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('style', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $style_plugin->definition['id'], '#description' => t('If the style you choose has settings, be sure to click the settings button that will appear next to it in the View summary.'));
             if ($style_plugin->usesOptions()) {
                 $form['markup'] = array('#prefix' => '<div class="form-item description">', '#suffix' => '</div>', '#markup' => t('You may also adjust the !settings for the currently selected style.', array('!settings' => $this->optionLink(t('settings'), 'style_options'))));
开发者ID:shumer,项目名称:blog,代码行数:67,代码来源:DisplayPluginBase.php

示例4: prepareView

 /**
  * Prepares a view executable by initializing everything which is needed.
  *
  * @param \Drupal\views\ViewExecutable $view
  *   The executable to prepare.
  */
 protected function prepareView(ViewExecutable $view)
 {
     $view->setDisplay();
     $view->initStyle();
     $view->initHandlers();
     $view->initQuery();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:13,代码来源:StyleTableUnitTest.php


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