• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP views\ViewExecutable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $types = ViewExecutable::getHandlerTypes();
     $view = $form_state->get('view');
     $display =& $view->getExecutable()->displayHandlers->get($form_state->get('display_id'));
     $remember_groups = array();
     if (!empty($view->form_cache)) {
         $old_fields = $view->form_cache['handlers'];
     } else {
         $old_fields = $display->getOption($types['filter']['plural']);
     }
     $groups = $form_state->getValue('filter_groups');
     // Whatever button was clicked, re-calculate field information.
     $new_fields = $order = array();
     // Make an array with the weights
     foreach ($form_state->getValue('filters') as $field => $info) {
         // add each value that is a field with a weight to our list, but only if
         // it has had its 'removed' checkbox checked.
         if (is_array($info) && empty($info['removed'])) {
             if (isset($info['weight'])) {
                 $order[$field] = $info['weight'];
             }
             if (isset($info['group'])) {
                 $old_fields[$field]['group'] = $info['group'];
                 $remember_groups[$info['group']][] = $field;
             }
         }
     }
     // Sort the array
     asort($order);
     // Create a new list of fields in the new order.
     foreach (array_keys($order) as $field) {
         $new_fields[$field] = $old_fields[$field];
     }
     // If the #group property is set on the clicked button, that means we are
     // either adding or removing a group, not actually updating the filters.
     $triggering_element = $form_state->getTriggeringElement();
     if (!empty($triggering_element['#group'])) {
         if ($triggering_element['#group'] == 'add') {
             // Add a new group
             $groups['groups'][] = 'AND';
         } else {
             // Renumber groups above the removed one down.
             foreach (array_keys($groups['groups']) as $group_id) {
                 if ($group_id >= $triggering_element['#group']) {
                     $old_group = $group_id + 1;
                     if (isset($groups['groups'][$old_group])) {
                         $groups['groups'][$group_id] = $groups['groups'][$old_group];
                         if (isset($remember_groups[$old_group])) {
                             foreach ($remember_groups[$old_group] as $id) {
                                 $new_fields[$id]['group'] = $group_id;
                             }
                         }
                     } else {
                         // If this is the last one, just unset it.
                         unset($groups['groups'][$group_id]);
                     }
                 }
             }
         }
         // Update our cache with values so that cancel still works the way
         // people expect.
         $view->form_cache = ['key' => 'rearrange-filter', 'groups' => $groups, 'handlers' => $new_fields];
         // Return to this form except on actual Update.
         $view->addFormToStack('rearrange-filter', $form_state->get('display_id'), 'filter');
     } else {
         // The actual update button was clicked. Remove the empty groups, and
         // renumber them sequentially.
         ksort($remember_groups);
         $groups['groups'] = static::arrayKeyPlus(array_values(array_intersect_key($groups['groups'], $remember_groups)));
         // Change the 'group' key on each field to match. Here, $mapping is an
         // array whose keys are the old group numbers and whose values are the new
         // (sequentially numbered) ones.
         $mapping = array_flip(static::arrayKeyPlus(array_keys($remember_groups)));
         foreach ($new_fields as &$new_field) {
             $new_field['group'] = $mapping[$new_field['group']];
         }
         // Write the changed handler values.
         $display->setOption($types['filter']['plural'], $new_fields);
         $display->setOption('filter_groups', $groups);
         if (isset($view->form_cache)) {
             unset($view->form_cache);
         }
     }
     // Store in cache.
     $view->cacheSet();
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:90,代码来源:RearrangeFilter.php


示例2: mappedOutputHelper

 /**
  * Tests the mapping of fields.
  *
  * @param \Drupal\views\ViewExecutable $view
  *   The view to test.
  *
  * @return string
  *   The view rendered as HTML.
  */
 protected function mappedOutputHelper($view)
 {
     $output = $view->preview();
     $rendered_output = \Drupal::service('renderer')->renderRoot($output);
     $this->storeViewPreview($rendered_output);
     $rows = $this->elements->body->div->div->div;
     $data_set = $this->dataSet();
     $count = 0;
     foreach ($rows as $row) {
         $attributes = $row->attributes();
         $class = (string) $attributes['class'][0];
         $this->assertTrue(strpos($class, 'views-row-mapping-test') !== FALSE, 'Make sure that each row has the correct CSS class.');
         foreach ($row->div as $field) {
             // Split up the field-level class, the first part is the mapping name
             // and the second is the field ID.
             $field_attributes = $field->attributes();
             $name = strtok((string) $field_attributes['class'][0], '-');
             $field_id = strtok('-');
             // The expected result is the mapping name and the field value,
             // separated by ':'.
             $expected_result = $name . ':' . $data_set[$count][$field_id];
             $actual_result = (string) $field;
             $this->assertIdentical($expected_result, $actual_result, format_string('The fields were mapped successfully: %name => %field_id', array('%name' => $name, '%field_id' => $field_id)));
         }
         $count++;
     }
     return $rendered_output;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:37,代码来源:StyleMappingTest.php


示例3: prepareView

 /**
  * Sets up the testing view with random field data.
  *
  * @param \Drupal\views\ViewExecutable $view
  *   The view to add field data to.
  */
 protected function prepareView(ViewExecutable $view)
 {
     $view->initDisplay();
     foreach ($this->fieldStorages as $field_storage) {
         $field_name = $field_storage->getName();
         $view->display_handler->options['fields'][$field_name]['id'] = $field_name;
         $view->display_handler->options['fields'][$field_name]['table'] = 'node__' . $field_name;
         $view->display_handler->options['fields'][$field_name]['field'] = $field_name;
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:16,代码来源:HandlerFieldFieldTest.php


示例4: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $view = $form_state['view'];
     $display_id = $form_state['display_id'];
     $type = $form_state['type'];
     $id = $form_state['id'];
     $form = array('options' => array('#tree' => true, '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE)));
     $executable = $view->getExecutable();
     $executable->setDisplay($display_id);
     $item = $executable->getHandler($display_id, $type, $id);
     if ($item) {
         $handler = $executable->display_handler->getHandler($type, $id);
         if (empty($handler)) {
             $form['markup'] = array('#markup' => $this->t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
         } else {
             $handler->init($executable, $executable->display_handler, $item);
             $types = ViewExecutable::getHandlerTypes();
             $form['#title'] = $this->t('Configure extra settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()));
             $form['#section'] = $display_id . '-' . $type . '-' . $id;
             // Get form from the handler.
             $handler->buildExtraOptionsForm($form['options'], $form_state);
             $form_state['handler'] = $handler;
         }
         $view->getStandardButtons($form, $form_state, 'views_ui_config_item_extra_form');
     }
     return $form;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:30,代码来源:ConfigHandlerExtra.php


示例5: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $view = $form_state->get('view');
     $display_id = $form_state->get('display_id');
     $type = $form_state->get('type');
     $id = $form_state->get('id');
     $form = array('options' => array('#tree' => TRUE, '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE)));
     $executable = $view->getExecutable();
     if (!$executable->setDisplay($display_id)) {
         $form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
         return $form;
     }
     $executable->initQuery();
     $item = $executable->getHandler($display_id, $type, $id);
     if ($item) {
         $handler = $executable->display_handler->getHandler($type, $id);
         if (empty($handler)) {
             $form['markup'] = array('#markup' => $this->t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
         } else {
             $handler->init($executable, $executable->display_handler, $item);
             $types = ViewExecutable::getHandlerTypes();
             $form['#title'] = $this->t('Configure aggregation settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()));
             $handler->buildGroupByForm($form['options'], $form_state);
             $form_state->set('handler', $handler);
         }
         $view->getStandardButtons($form, $form_state, 'views_ui_config_item_group_form');
     }
     return $form;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:32,代码来源:ConfigHandlerGroup.php


示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     // Ensure that the plugin definitions are cleared.
     foreach (ViewExecutable::getPluginTypes() as $plugin_type) {
         $this->container->get("plugin.manager.views.{$plugin_type}")->clearCachedDefinitions();
     }
     ViewTestData::createTestViews(get_class($this), array('ds_test'));
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:9,代码来源:ViewsTest.php


示例7: assertViewsCacheTags

 /**
  * Asserts a view's result & output cache items' cache tags.
  *
  * @param \Drupal\views\ViewExecutable $view
  *   The view to test, must have caching enabled.
  * @param null|string[] $expected_results_cache
  *   NULL when expecting no results cache item, a set of cache tags expected
  *   to be set on the results cache item otherwise.
  * @param bool $views_caching_is_enabled
  *   Whether to expect an output cache item. If TRUE, the cache tags must
  *   match those in $expected_render_array_cache_tags.
  * @param string[] $expected_render_array_cache_tags
  *   A set of cache tags expected to be set on the built view's render array.
  *
  * @return array
  *   The render array
  */
 protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_cache, $views_caching_is_enabled, array $expected_render_array_cache_tags)
 {
     $build = $view->preview();
     // 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_stack->push(new Request());
     \Drupal::service('renderer')->renderRoot($build);
     $request_stack->pop();
     // 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);
     if ($views_caching_is_enabled) {
         $this->pass('Checking Views results cache item cache tags.');
         /** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache_plugin */
         $cache_plugin = $view->display_handler->getPlugin('cache');
         // Results cache.
         $results_cache_item = \Drupal::cache('data')->get($cache_plugin->generateResultsKey());
         if (is_array($expected_results_cache)) {
             $this->assertTrue($results_cache_item, 'Results cache item found.');
             if ($results_cache_item) {
                 sort($expected_results_cache);
                 $this->assertEqual($results_cache_item->tags, $expected_results_cache);
             }
         } else {
             $this->assertFalse($results_cache_item, 'Results cache item not found.');
         }
         // Output cache.
         $this->pass('Checking Views output cache item cache tags.');
         $output_cache_item = \Drupal::cache('render')->get($cache_plugin->generateOutputKey());
         if ($views_caching_is_enabled === TRUE) {
             $this->assertTrue($output_cache_item, 'Output cache item found.');
             if ($output_cache_item) {
                 $this->assertEqual($output_cache_item->tags, Cache::mergeTags($expected_render_array_cache_tags, ['rendered']));
             }
         } else {
             $this->assertFalse($output_cache_item, 'Output cache item not found.');
         }
     }
     $view->destroy();
     return $build;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:61,代码来源:AssertViewsCacheTagsTrait.php


示例8: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->entityManager = $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->entityStorage = $this->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
     $this->entityViewBuilder = $this->getMock('Drupal\\Core\\Entity\\EntityViewBuilderInterface');
     $this->executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')->disableOriginalConstructor()->getMock();
     $this->display = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')->disableOriginalConstructor()->getMock();
     $this->stylePlugin = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\style\\StylePluginBase')->disableOriginalConstructor()->getMock();
     $this->executable->style_plugin = $this->stylePlugin;
     $this->entityHandler = new Entity(array(), 'entity', array('entity_type' => 'entity_test'), $this->entityManager);
     $this->display->expects($this->any())->method('getPlugin')->with('style')->willReturn($this->stylePlugin);
     $this->executable->expects($this->any())->method('getStyle')->willReturn($this->stylePlugin);
     $token = $this->getMockBuilder('Drupal\\Core\\Utility\\Token')->disableOriginalConstructor()->getMock();
     $token->expects($this->any())->method('replace')->willReturnArgument(0);
     $container = new ContainerBuilder();
     $container->set('token', $token);
     \Drupal::setContainer($container);
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:22,代码来源:EntityTest.php


示例9: testBuildThemeFunctions

 /**
  * Tests the buildThemeFunctions() method.
  */
 public function testBuildThemeFunctions()
 {
     $config = array('id' => 'test_view', 'tag' => 'OnE, TWO, and three', 'display' => array('default' => array('id' => 'default', 'display_plugin' => 'default', 'display_title' => 'Default')));
     $storage = new View($config, 'view');
     $user = $this->getMock('Drupal\\Core\\Session\\AccountInterface');
     $view = new ViewExecutable($storage, $user);
     $expected = array('test_hook__test_view', 'test_hook');
     $this->assertEquals($expected, $view->buildThemeFunctions('test_hook'));
     // Add a mock display.
     $display = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')->disableOriginalConstructor()->getMock();
     $display->display = $config['display']['default'];
     $view->display_handler = $display;
     $expected = array('test_hook__test_view__default', 'test_hook__default', 'test_hook__one', 'test_hook__two', 'test_hook__and_three', 'test_hook__test_view', 'test_hook');
     $this->assertEquals($expected, $view->buildThemeFunctions('test_hook'));
     //Change the name of the display plugin and make sure that is in the array.
     $view->display_handler->display['display_plugin'] = 'default2';
     $expected = array('test_hook__test_view__default', 'test_hook__default', 'test_hook__one', 'test_hook__two', 'test_hook__and_three', 'test_hook__test_view__default2', 'test_hook__default2', 'test_hook__test_view', 'test_hook');
     $this->assertEquals($expected, $view->buildThemeFunctions('test_hook'));
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:22,代码来源:ViewExecutableUnitTest.php


示例10: testHandlers

 /**
  * Tests most of the handlers.
  */
 public function testHandlers()
 {
     $this->drupalCreateContentType(array('type' => 'article'));
     $this->addDefaultCommentField('node', 'article');
     $object_types = array_keys(ViewExecutable::getHandlerTypes());
     foreach ($this->container->get('views.views_data')->get() as $base_table => $info) {
         if (!isset($info['table']['base'])) {
             continue;
         }
         $view = entity_create('view', array('base_table' => $base_table));
         $view = $view->getExecutable();
         // @todo The groupwise relationship is currently broken.
         $exclude[] = 'taxonomy_term_field_data:tid_representative';
         $exclude[] = 'users_field_data:uid_representative';
         // Go through all fields and there through all handler types.
         foreach ($info as $field => $field_info) {
             // Table is a reserved key for the metainformation.
             if ($field != 'table' && !in_array("{$base_table}:{$field}", $exclude)) {
                 $item = array('table' => $base_table, 'field' => $field);
                 foreach ($object_types as $type) {
                     if (isset($field_info[$type]['id'])) {
                         $options = array();
                         if ($type == 'filter') {
                             $handler = $this->container->get("plugin.manager.views.{$type}")->getHandler($item);
                             // Set the value to use for the filter based on the filter type.
                             if ($handler instanceof InOperator) {
                                 $options['value'] = array(1);
                             } else {
                                 $options['value'] = 1;
                             }
                         }
                         $view->addHandler('default', $type, $base_table, $field, $options);
                     }
                 }
             }
         }
         // Go through each step individually to see whether some parts are
         // failing.
         $view->build();
         $view->preExecute();
         $view->execute();
         $view->render();
         // Make sure all handlers extend the HandlerBase.
         foreach ($object_types as $type) {
             if (isset($view->{$type})) {
                 foreach ($view->{$type} as $handler) {
                     $this->assertTrue($handler instanceof HandlerBase, format_string('@type handler of class %class is an instance of HandlerBase', array('@type' => $type, '%class' => get_class($handler))));
                 }
             }
         }
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:55,代码来源:HandlerAllTest.php


示例11: viewsData

 /**
  * {@inheritdoc}
  */
 protected function viewsData()
 {
     $data = parent::viewsData();
     // Override the name handler to be able to call placeholder() from outside.
     $data['views_test_data']['name']['field']['id'] = 'test_field';
     // Setup one field with an access callback and one with an access callback
     // and arguments.
     $data['views_test_data']['access_callback'] = $data['views_test_data']['id'];
     $data['views_test_data']['access_callback_arguments'] = $data['views_test_data']['id'];
     foreach (ViewExecutable::getHandlerTypes() as $type => $info) {
         if (isset($data['views_test_data']['access_callback'][$type]['id'])) {
             $data['views_test_data']['access_callback'][$type]['access callback'] = 'views_test_data_handler_test_access_callback';
             $data['views_test_data']['access_callback_arguments'][$type]['access callback'] = 'views_test_data_handler_test_access_callback_argument';
             $data['views_test_data']['access_callback_arguments'][$type]['access arguments'] = array(TRUE);
         }
     }
     return $data;
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:21,代码来源:HandlerTest.php


示例12: reportFields

 /**
  * Lists all instances of fields on any views.
  *
  * @return array
  *   The Views fields report page.
  */
 public function reportFields()
 {
     $views = $this->entityManager()->getStorage('view')->loadMultiple();
     // Fetch all fieldapi fields which are used in views
     // Therefore search in all views, displays and handler-types.
     $fields = array();
     $handler_types = ViewExecutable::getHandlerTypes();
     foreach ($views as $view) {
         $executable = $view->getExecutable();
         $executable->initDisplay();
         foreach ($executable->displayHandlers as $display_id => $display) {
             if ($executable->setDisplay($display_id)) {
                 foreach ($handler_types as $type => $info) {
                     foreach ($executable->getHandlers($type, $display_id) as $item) {
                         $table_data = $this->viewsData->get($item['table']);
                         if (isset($table_data[$item['field']]) && isset($table_data[$item['field']][$type]) && ($field_data = $table_data[$item['field']][$type])) {
                             // The final check that we have a fieldapi field now.
                             if (isset($field_data['field_name'])) {
                                 $fields[$field_data['field_name']][$view->id()] = $view->id();
                             }
                         }
                     }
                 }
             }
         }
     }
     $header = array(t('Field name'), t('Used in'));
     $rows = array();
     foreach ($fields as $field_name => $views) {
         $rows[$field_name]['data'][0]['data']['#plain_text'] = $field_name;
         foreach ($views as $view) {
             $rows[$field_name]['data'][1][] = $this->l($view, new Url('entity.view.edit_form', array('view' => $view)));
         }
         $item_list = ['#theme' => 'item_list', '#items' => $rows[$field_name]['data'][1], '#context' => ['list_style' => 'comma-list']];
         $rows[$field_name]['data'][1] = ['data' => $item_list];
     }
     // Sort rows by field name.
     ksort($rows);
     $output = array('#type' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => t('No fields have been used in views yet.'));
     return $output;
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:47,代码来源:ViewsUIController.php


示例13: reportFields

 /**
  * Lists all instances of fields on any views.
  *
  * @return array
  *   The Views fields report page.
  */
 public function reportFields()
 {
     $views = $this->entityManager()->getStorage('view')->loadMultiple();
     // Fetch all fieldapi fields which are used in views
     // Therefore search in all views, displays and handler-types.
     $fields = array();
     $handler_types = ViewExecutable::getHandlerTypes();
     foreach ($views as $view) {
         $executable = $view->getExecutable();
         $executable->initDisplay();
         foreach ($executable->displayHandlers as $display_id => $display) {
             if ($executable->setDisplay($display_id)) {
                 foreach ($handler_types as $type => $info) {
                     foreach ($executable->getHandlers($type, $display_id) as $item) {
                         $table_data = $this->viewsData->get($item['table']);
                         if (isset($table_data[$item['field']]) && isset($table_data[$item['field']][$type]) && ($field_data = $table_data[$item['field']][$type])) {
                             // The final check that we have a fieldapi field now.
                             if (isset($field_data['field_name'])) {
                                 $fields[$field_data['field_name']][$view->id()] = $view->id();
                             }
                         }
                     }
                 }
             }
         }
     }
     $header = array(t('Field name'), t('Used in'));
     $rows = array();
     foreach ($fields as $field_name => $views) {
         $rows[$field_name]['data'][0] = String::checkPlain($field_name);
         foreach ($views as $view) {
             $rows[$field_name]['data'][1][] = $this->l($view, 'views_ui.edit', array('view' => $view));
         }
         $rows[$field_name]['data'][1] = SafeMarkup::set(implode(', ', $rows[$field_name]['data'][1]));
     }
     // Sort rows by field name.
     ksort($rows);
     $output = array('#type' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => t('No fields have been used in views yet.'));
     return $output;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:46,代码来源:ViewsUIController.php


示例14: 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


示例15: 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


示例16: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $view = $form_state->get('view');
     $display_id = $form_state->get('display_id');
     $type = $form_state->get('type');
     $form = array('options' => array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE)));
     $executable = $view->getExecutable();
     $executable->setDisplay($display_id);
     $display =& $executable->displayHandlers->get($display_id);
     $types = ViewExecutable::getHandlerTypes();
     $ltitle = $types[$type]['ltitle'];
     $section = $types[$type]['plural'];
     if (!empty($types[$type]['type'])) {
         $type = $types[$type]['type'];
     }
     $form['#title'] = $this->t('Add @type', array('@type' => $ltitle));
     $form['#section'] = $display_id . 'add-handler';
     // Add the display override dropdown.
     views_ui_standard_display_dropdown($form, $form_state, $section);
     // Figure out all the base tables allowed based upon what the relationships provide.
     $base_tables = $executable->getBaseTables();
     $options = Views::viewsDataHelper()->fetchFields(array_keys($base_tables), $type, $display->useGroupBy(), $form_state->get('type'));
     if (!empty($options)) {
         $form['override']['controls'] = array('#theme_wrappers' => array('container'), '#id' => 'views-filterable-options-controls', '#attributes' => array('class' => array('container-inline')));
         $form['override']['controls']['options_search'] = array('#type' => 'textfield', '#title' => $this->t('Search'));
         $groups = array('all' => $this->t('- All -'));
         $form['override']['controls']['group'] = array('#type' => 'select', '#title' => $this->t('Type'), '#options' => array());
         $form['options']['name'] = array('#prefix' => '<div class="views-radio-box form-checkboxes views-filterable-options">', '#suffix' => '</div>', '#tree' => TRUE, '#default_value' => 'all');
         // Group options first to simplify the usage of #states.
         $grouped_options = array();
         foreach ($options as $key => $option) {
             $group = preg_replace('/[^a-z0-9]/', '-', strtolower($option['group']));
             $groups[$group] = $option['group'];
             $grouped_options[$group][$key] = $option;
             if (!empty($option['aliases']) && is_array($option['aliases'])) {
                 foreach ($option['aliases'] as $id => $alias) {
                     if (empty($alias['base']) || !empty($base_tables[$alias['base']])) {
                         $copy = $option;
                         $copy['group'] = $alias['group'];
                         $copy['title'] = $alias['title'];
                         if (isset($alias['help'])) {
                             $copy['help'] = $alias['help'];
                         }
                         $group = preg_replace('/[^a-z0-9]/', '-', strtolower($copy['group']));
                         $groups[$group] = $copy['group'];
                         $grouped_options[$group][$key . '$' . $id] = $copy;
                     }
                 }
             }
         }
         foreach ($grouped_options as $group => $group_options) {
             foreach ($group_options as $key => $option) {
                 $form['options']['name'][$key] = array('#type' => 'checkbox', '#title' => $this->t('!group: !field', array('!group' => $option['group'], '!field' => $option['title'])), '#description' => $option['help'], '#return_value' => $key, '#prefix' => "<div class='filterable-option'>", '#suffix' => '</div>', '#states' => array('visible' => array(array(':input[name="override[controls][group]"]' => array('value' => 'all')), array(':input[name="override[controls][group]"]' => array('value' => $group)))));
             }
         }
         $form['override']['controls']['group']['#options'] = $groups;
     } else {
         $form['options']['markup'] = array('#markup' => '<div class="form-item">' . $this->t('There are no @types available to add.', array('@types' => $ltitle)) . '</div>');
     }
     // Add a div to show the selected items
     $form['selected'] = array('#type' => 'item', '#markup' => '<span class="views-ui-view-title">' . $this->t('Selected:') . '</span> ' . '<div class="views-selected-options"></div>', '#theme_wrappers' => array('form_element', 'views_ui_container'), '#attributes' => array('class' => array('container-inline', 'views-add-form-selected'), 'data-drupal-views-offset' => 'bottom'));
     $view->getStandardButtons($form, $form_state, 'views_ui_add_handler_form', $this->t('Add and configure @types', array('@types' => $ltitle)));
     // Remove the default submit function.
     $form['actions']['submit']['#submit'] = array_filter($form['actions']['submit']['#submit'], function ($var) {
         return !(is_array($var) && isset($var[1]) && $var[1] == 'standardSubmit');
     });
     $form['actions']['submit']['#submit'][] = array($view, 'submitItemAdd');
     return $form;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:72,代码来源:AddHandler.php


示例17: mergeHandler

 /**
  * Merges handlers default values.
  *
  * @param string $type
  *   The name of the handler type option.
  */
 protected function mergeHandler($type)
 {
     $types = ViewExecutable::getHandlerTypes();
     $options = $this->getOption($types[$type]['plural']);
     foreach ($this->getHandlers($type) as $id => $handler) {
         if (isset($options[$id])) {
             $options[$id] = $options[$id] + $handler->options;
         }
     }
     $this->setOption($types[$type]['plural'], $options);
 }
开发者ID:318io,项目名称:318-io,代码行数:17,代码来源:DisplayPluginBase.php


示例18: submitTemporaryForm

 /**
  * A submit handler that is used for storing temporary items when using
  * multi-step changes, such as ajax requests.
  */
 public function submitTemporaryForm($form, FormStateInterface $form_state)
 {
     // Run it through the handler's submit function.
     $this->submitOptionsForm($form['options'], $form_state);
     $item = $this->options;
     $types = ViewExecutable::getHandlerTypes();
     // For footer/header $handler_type is area but $type is footer/header.
     // For all other handle types it's the same.
     $handler_type = $type = $form_state->get('type');
     if (!empty($types[$type]['type'])) {
         $handler_type = $types[$type]['type'];
     }
     $override = NULL;
     $view = $form_state->get('view');
     $executable = $view->getExecutable();
     if ($executable->display_handler->useGroupBy() && !empty($item['group_type'])) {
         if (empty($executable->query)) {
             $executable->initQuery();
         }
         $aggregate = $executable->query->getAggregationInfo();
         if (!empty($aggregate[$item['group_type']]['handler'][$type])) {
             $override = $aggregate[$item['group_type']]['handler'][$type];
         }
     }
     // Create a new handler and unpack the options from the form onto it. We
     // can use that for storage.
     $handler = Views::handlerManager($handler_type)->getHandler($item, $override);
     $handler->init($executable, $executable->display_handler, $item);
     // Add the incoming options to existing options because items using
     // the extra form may not have everything in the form here.
     $options = $form_state->getValue('options') + $this->options;
     // This unpacks only options that are in the definition, ensuring random
     // extra stuff on the form is not sent through.
     $handler->unpackOptions($handler->options, $options, NULL, FALSE);
     // Store the item back on the view.
     $executable = $view->getExecutable();
     $executable->temporary_options[$type][$form_state->get('id')] = $handler->options;
     // @todo Decide if \Drupal\views_ui\Form\Ajax\ViewsFormBase::getForm() is
     //   perhaps the better place to fix the issue.
     // \Drupal\views_ui\Form\Ajax\ViewsFormBase::getForm() drops the current
     // form from the stack, even if it's an #ajax. So add the item back to the top
     // of the stack.
     $view->addFormToStack($form_state->get('form_key'), $form_state->get('display_id'), $type, $item['id'], TRUE);
     $form_state->get('rerender', TRUE);
     $form_state->setRebuild();
     // Write to  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP views\Views类代码示例发布时间:2022-05-23
下一篇:
PHP views\EntityViewsData类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap