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


PHP views\ViewExecutable类代码示例

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


在下文中一共展示了ViewExecutable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: isBaseTableTranslatable

 /**
  * Returns whether the base table is of a translatable entity type.
  *
  * @return bool
  *   TRUE if the base table is of a translatable entity type, FALSE otherwise.
  */
 protected function isBaseTableTranslatable()
 {
     if ($entity_type = $this->view->getBaseEntityType()) {
         return $entity_type->isTranslatable();
     }
     return FALSE;
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:13,代码来源:DisplayPluginBase.php


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