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


PHP Views::getView方法代码示例

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


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

示例1: testUserUid

 /**
  * Tests the user uid filter and argument.
  */
 public function testUserUid()
 {
     $map = array('nid' => 'nid', 'title' => 'title');
     $expected = array(array('nid' => $this->node->id(), 'title' => $this->node->label()));
     $view = Views::getView('test_tracker_user_uid');
     $this->executeView($view);
     // We should have no results as the filter is set for uid 0.
     $this->assertIdenticalResultSet($view, array(), $map);
     $view->destroy();
     // Change the filter value to our user.
     $view->initHandlers();
     $view->filter['uid_touch_tracker']->value = $this->node->getOwnerId();
     $this->executeView($view);
     // We should have one result as the filter is set for the created user.
     $this->assertIdenticalResultSet($view, $expected, $map);
     $view->destroy();
     // Remove the filter now, so only the argument will affect the query.
     $view->removeHandler('default', 'filter', 'uid_touch_tracker');
     // Test the incorrect argument UID.
     $view->initHandlers();
     $this->executeView($view, array(rand()));
     $this->assertIdenticalResultSet($view, array(), $map);
     $view->destroy();
     // Test the correct argument UID.
     $view->initHandlers();
     $this->executeView($view, array($this->node->getOwnerId()));
     $this->assertIdenticalResultSet($view, $expected, $map);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:31,代码来源:TrackerUserUidTest.php

示例2: testIntegration

 /**
  * Tests the integration.
  */
 public function testIntegration()
 {
     // Remove the watchdog entries added by the potential batch process.
     $this->container->get('database')->truncate('watchdog')->execute();
     $entries = array();
     // Setup a watchdog entry without tokens.
     $entries[] = array('message' => $this->randomMachineName(), 'variables' => array(), 'link' => l('Link', 'node/1'));
     // Setup a watchdog entry with one token.
     $entries[] = array('message' => '@token1', 'variables' => array('@token1' => $this->randomMachineName()), 'link' => l('Link', 'node/2'));
     // Setup a watchdog entry with two tokens.
     $entries[] = array('message' => '@token1 !token2', 'variables' => array('@token1' => $this->randomMachineName(), '!token2' => $this->randomMachineName()), 'link' => l('<object>Link</object>', 'node/2', array('html' => TRUE)));
     foreach ($entries as $entry) {
         $entry += array('type' => 'test-views', 'severity' => WATCHDOG_NOTICE);
         watchdog($entry['type'], $entry['message'], $entry['variables'], $entry['severity'], $entry['link']);
     }
     $view = Views::getView('test_dblog');
     $this->executeView($view);
     $view->initStyle();
     foreach ($entries as $index => $entry) {
         $this->assertEqual($view->style_plugin->getField($index, 'message'), String::format($entry['message'], $entry['variables']));
         $this->assertEqual($view->style_plugin->getField($index, 'link'), Xss::filterAdmin($entry['link']));
     }
     // Disable replacing variables and check that the tokens aren't replaced.
     $view->destroy();
     $view->initHandlers();
     $this->executeView($view);
     $view->initStyle();
     $view->field['message']->options['replace_variables'] = FALSE;
     foreach ($entries as $index => $entry) {
         $this->assertEqual($view->style_plugin->getField($index, 'message'), $entry['message']);
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:35,代码来源:ViewsIntegrationTest.php

示例3: testCalculateDependencies

 /**
  * Tests the calculateDependencies method.
  */
 public function testCalculateDependencies()
 {
     $comment_type = entity_create('comment_type', array('id' => 'comment', 'label' => 'Comment settings', 'description' => 'Comment settings', 'target_entity_type_id' => 'node'));
     $comment_type->save();
     $content_type = entity_create('node_type', array('type' => $this->randomMachineName(), 'name' => $this->randomString()));
     $content_type->save();
     $field_storage = entity_create('field_storage_config', array('field_name' => Unicode::strtolower($this->randomMachineName()), 'entity_type' => 'node', 'type' => 'comment'));
     $field_storage->save();
     entity_create('field_config', array('field_storage' => $field_storage, 'bundle' => $content_type->id(), 'label' => $this->randomMachineName() . '_label', 'description' => $this->randomMachineName() . '_description', 'settings' => array('comment_type' => $comment_type->id())))->save();
     entity_create('field_config', array('field_storage' => FieldStorageConfig::loadByName('node', 'body'), 'bundle' => $content_type->id(), 'label' => $this->randomMachineName() . '_body', 'settings' => array('display_summary' => TRUE)))->save();
     $expected = [];
     $expected['test_field_get_entity'] = ['module' => ['comment', 'node', 'user']];
     // Tests dependencies of relationships.
     $expected['test_relationship_dependency'] = ['module' => ['comment', 'node', 'user']];
     $expected['test_plugin_dependencies'] = ['module' => ['comment', 'views_test_data'], 'content' => ['RowTest', 'StaticTest', 'StyleTest']];
     $expected['test_argument_dependency'] = ['config' => ['core.entity_view_mode.node.teaser', 'field.storage.node.body'], 'content' => ['ArgumentDefaultTest', 'ArgumentValidatorTest'], 'module' => ['node', 'search', 'text', 'user']];
     foreach ($this::$testViews as $view_id) {
         $view = Views::getView($view_id);
         $dependencies = $view->calculateDependencies();
         $this->assertEqual($expected[$view_id], $dependencies);
         $config = $this->config('views.view.' . $view_id);
         \Drupal::service('config.storage.staging')->write($view_id, $config->get());
     }
     // Ensure that dependencies are calculated on the display level.
     $expected_display['default'] = ['config' => ['core.entity_view_mode.node.teaser'], 'content' => ['ArgumentDefaultTest', 'ArgumentValidatorTest'], 'module' => ['core', 'node', 'search', 'user', 'views']];
     $expected_display['page'] = ['config' => ['field.storage.node.body'], 'module' => ['core', 'text', 'views']];
     $view = Views::getView('test_argument_dependency');
     $view->initDisplay();
     foreach ($view->displayHandlers as $display) {
         // Calculate the dependencies each display has.
         $this->assertEqual($expected_display[$display->getPluginId()], $display->calculateDependencies());
     }
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:36,代码来源:ViewEntityDependenciesTest.php

示例4: testUsername

 /**
  * Test the username formatter.
  */
 public function testUsername()
 {
     $view_id = $this->randomMachineName();
     $view = View::create(['id' => $view_id, 'base_table' => 'comment_field_data', 'display' => ['default' => ['display_plugin' => 'default', 'id' => 'default', 'display_options' => ['fields' => ['name' => ['table' => 'comment_field_data', 'field' => 'name', 'id' => 'name', 'plugin_id' => 'field', 'type' => 'comment_username'], 'subject' => ['table' => 'comment_field_data', 'field' => 'subject', 'id' => 'subject', 'plugin_id' => 'field', 'type' => 'string', 'settings' => ['link_to_entity' => TRUE]]]]]]]);
     $view->save();
     /* @var \Drupal\Core\Session\AccountSwitcherInterface $account_switcher */
     $account_switcher = \Drupal::service('account_switcher');
     /* @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = \Drupal::service('renderer');
     $account_switcher->switchTo($this->adminUser);
     $executable = Views::getView($view_id);
     $build = $executable->preview();
     $this->setRawContent($renderer->renderRoot($build));
     $this->verbose($this->getRawContent());
     $this->assertLink('My comment title');
     $this->assertLink('Anonymous comment title');
     $this->assertLink($this->adminUser->label());
     $this->assertLink('barry (not verified)');
     $account_switcher->switchTo(new AnonymousUserSession());
     $executable = Views::getView($view_id);
     $executable->storage->invalidateCaches();
     $build = $executable->preview();
     $this->setRawContent($renderer->renderRoot($build));
     // No access to user-profiles, so shouldn't be able to see links.
     $this->assertNoLink($this->adminUser->label());
     // Note: External users aren't pointing to drupal user profiles.
     $this->assertLink('barry (not verified)');
     $this->verbose($this->getRawContent());
     $this->assertLink('My comment title');
     $this->assertLink('Anonymous comment title');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:34,代码来源:CommentUserNameTest.php

示例5: testHooks

 /**
  * Tests the hooks.
  */
 public function testHooks()
 {
     $view = Views::getView('test_view');
     $view->setDisplay();
     // Test each hook is found in the implementations array and is invoked.
     foreach (static::$hooks as $hook => $type) {
         $this->assertTrue($this->moduleHandler->implementsHook('views_test_data', $hook), format_string('The hook @hook was registered.', array('@hook' => $hook)));
         if ($hook == 'views_post_render') {
             $this->moduleHandler->invoke('views_test_data', $hook, array($view, &$view->display_handler->output, $view->display_handler->getPlugin('cache')));
             continue;
         }
         switch ($type) {
             case 'view':
                 $this->moduleHandler->invoke('views_test_data', $hook, array($view));
                 break;
             case 'alter':
                 $data = array();
                 $this->moduleHandler->invoke('views_test_data', $hook, array($data));
                 break;
             default:
                 $this->moduleHandler->invoke('views_test_data', $hook);
         }
         $this->assertTrue($this->container->get('state')->get('views_hook_test_' . $hook), format_string('The %hook hook was invoked.', array('%hook' => $hook)));
         // Reset the module implementations cache, so we ensure that the
         // .views.inc file is loaded actively.
         $this->moduleHandler->resetImplementations();
     }
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:31,代码来源:ViewsHooksTest.php

示例6: testFileExtensionTarOption

 /**
  * Tests file extension views field handler extension_detect_tar option.
  */
 public function testFileExtensionTarOption()
 {
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = \Drupal::service('renderer');
     $view = Views::getView('file_extension_view');
     $view->setDisplay();
     $this->executeView($view);
     // Test without the tar option.
     $renderer->executeInRenderContext(new RenderContext(), function () use($view) {
         $this->assertEqual($view->field['extension']->advancedRender($view->result[0]), 'png');
         $this->assertEqual($view->field['extension']->advancedRender($view->result[1]), 'tar');
         $this->assertEqual($view->field['extension']->advancedRender($view->result[2]), 'gz');
         $this->assertEqual($view->field['extension']->advancedRender($view->result[3]), '');
     });
     // Test with the tar option.
     $view = Views::getView('file_extension_view');
     $view->setDisplay();
     $view->initHandlers();
     $view->field['extension']->options['settings']['extension_detect_tar'] = TRUE;
     $this->executeView($view);
     $renderer->executeInRenderContext(new RenderContext(), function () use($view) {
         $this->assertEqual($view->field['extension']->advancedRender($view->result[0]), 'png');
         $this->assertEqual($view->field['extension']->advancedRender($view->result[1]), 'tar');
         $this->assertEqual($view->field['extension']->advancedRender($view->result[2]), 'tar.gz');
         $this->assertEqual($view->field['extension']->advancedRender($view->result[3]), '');
     });
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:30,代码来源:ExtensionViewsFieldTest.php

示例7: testSimple

 function testSimple()
 {
     $view = Views::getView('test_view');
     $view->setDisplay();
     $view->displayHandlers->get('default')->overrideOption('fields', array('counter' => array('id' => 'counter', 'table' => 'views', 'field' => 'counter', 'relationship' => 'none'), 'name' => array('id' => 'name', 'table' => 'views_test_data', 'field' => 'name', 'relationship' => 'none')));
     $view->preview();
     $counter = $view->style_plugin->getField(0, 'counter');
     $this->assertEqual($counter, '1', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 1, '@counter' => $counter)));
     $counter = $view->style_plugin->getField(1, 'counter');
     $this->assertEqual($counter, '2', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 2, '@counter' => $counter)));
     $counter = $view->style_plugin->getField(2, 'counter');
     $this->assertEqual($counter, '3', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 3, '@counter' => $counter)));
     $view->destroy();
     $view->storage->invalidateCaches();
     $view->setDisplay();
     $rand_start = rand(5, 10);
     $view->displayHandlers->get('default')->overrideOption('fields', array('counter' => array('id' => 'counter', 'table' => 'views', 'field' => 'counter', 'relationship' => 'none', 'counter_start' => $rand_start), 'name' => array('id' => 'name', 'table' => 'views_test_data', 'field' => 'name', 'relationship' => 'none')));
     $view->preview();
     $counter = $view->style_plugin->getField(0, 'counter');
     $expected_number = 0 + $rand_start;
     $this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
     $counter = $view->style_plugin->getField(1, 'counter');
     $expected_number = 1 + $rand_start;
     $this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
     $counter = $view->style_plugin->getField(2, 'counter');
     $expected_number = 2 + $rand_start;
     $this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:28,代码来源:FieldCounterTest.php

示例8: testCommentFieldName

 /**
  * Test comment field name.
  */
 public function testCommentFieldName()
 {
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = \Drupal::service('renderer');
     $view = Views::getView('test_comment_field_name');
     $this->executeView($view);
     $expected_result = [['cid' => $this->comment->id(), 'field_name' => $this->comment->getFieldName()], ['cid' => $this->customComment->id(), 'field_name' => $this->customComment->getFieldName()]];
     $column_map = ['cid' => 'cid', 'comment_field_data_field_name' => 'field_name'];
     $this->assertIdenticalResultset($view, $expected_result, $column_map);
     // Test that no data can be rendered.
     $this->assertIdentical(FALSE, isset($view->field['field_name']));
     // Grant permission to properly check view access on render.
     user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access comments']);
     $this->container->get('account_switcher')->switchTo(new AnonymousUserSession());
     $view = Views::getView('test_comment_field_name');
     $this->executeView($view);
     // Test that data rendered.
     $output = $renderer->executeInRenderContext(new RenderContext(), function () use($view) {
         return $view->field['field_name']->advancedRender($view->result[0]);
     });
     $this->assertIdentical($this->comment->getFieldName(), $output);
     $output = $renderer->executeInRenderContext(new RenderContext(), function () use($view) {
         return $view->field['field_name']->advancedRender($view->result[1]);
     });
     $this->assertIdentical($this->customComment->getFieldName(), $output);
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:29,代码来源:CommentFieldNameTest.php

示例9: testHandlers

 /**
  * Tests the handlers.
  */
 public function testHandlers()
 {
     $nodes = array();
     $nodes[] = $this->drupalCreateNode();
     $nodes[] = $this->drupalCreateNode();
     $account = $this->drupalCreateUser();
     $this->drupalLogin($account);
     \Drupal::currentUser()->setAccount($account);
     db_insert('history')->fields(array('uid' => $account->id(), 'nid' => $nodes[0]->id(), 'timestamp' => REQUEST_TIME - 100))->execute();
     db_insert('history')->fields(array('uid' => $account->id(), 'nid' => $nodes[1]->id(), 'timestamp' => REQUEST_TIME + 100))->execute();
     $column_map = array('nid' => 'nid');
     // Test the history field.
     $view = Views::getView('test_history');
     $view->setDisplay('page_1');
     $this->executeView($view);
     $this->assertEqual(count($view->result), 2);
     $output = $view->preview();
     $this->setRawContent(\Drupal::service('renderer')->renderRoot($output));
     $result = $this->xpath('//span[@class=:class]', array(':class' => 'marker'));
     $this->assertEqual(count($result), 1, 'Just one node is marked as new');
     // Test the history filter.
     $view = Views::getView('test_history');
     $view->setDisplay('page_2');
     $this->executeView($view);
     $this->assertEqual(count($view->result), 1);
     $this->assertIdenticalResultset($view, array(array('nid' => $nodes[0]->id())), $column_map);
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:30,代码来源:HistoryTimestampTest.php

示例10: testCalculateDependencies

 /**
  * Tests the calculateDependencies method.
  */
 public function testCalculateDependencies()
 {
     $expected = [];
     $expected['test_field_get_entity'] = ['module' => ['comment', 'node', 'user']];
     // Tests dependencies of relationships.
     $expected['test_relationship_dependency'] = ['module' => ['comment', 'node', 'user']];
     $expected['test_plugin_dependencies'] = ['module' => ['comment', 'views_test_data'], 'content' => ['RowTest', 'StaticTest', 'StyleTest']];
     $expected['test_argument_dependency'] = ['config' => ['core.entity_view_mode.node.teaser', 'field.storage.node.body'], 'content' => ['ArgumentDefaultTest', 'ArgumentValidatorTest'], 'module' => ['node', 'search', 'text', 'user']];
     foreach ($this::$testViews as $view_id) {
         $view = Views::getView($view_id);
         $dependencies = $view->calculateDependencies();
         $this->assertEqual($expected[$view_id], $dependencies);
         $config = $this->config('views.view.' . $view_id);
         \Drupal::service('config.storage.staging')->write($view_id, $config->get());
     }
     // Ensure that dependencies are calculated on the display level.
     $expected_display['default'] = ['config' => ['core.entity_view_mode.node.teaser'], 'content' => ['ArgumentDefaultTest', 'ArgumentValidatorTest'], 'module' => ['core', 'node', 'search', 'user', 'views']];
     $expected_display['page'] = ['config' => ['field.storage.node.body'], 'module' => ['core', 'text', 'views']];
     $view = Views::getView('test_argument_dependency');
     $view->initDisplay();
     foreach ($view->displayHandlers as $display) {
         // Calculate the dependencies each display has.
         $this->assertEqual($expected_display[$display->getPluginId()], $display->calculateDependencies());
     }
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:28,代码来源:ViewEntityDependenciesTest.php

示例11: testUserName

 public function testUserName()
 {
     $this->drupalLogin($this->drupalCreateUser(array('access user profiles')));
     $view = Views::getView('test_views_handler_field_user_name');
     $this->executeView($view);
     $view->field['name']->options['link_to_user'] = TRUE;
     $username = $view->result[0]->users_field_data_name = $this->randomMachineName();
     $view->result[0]->users_field_data_uid = 1;
     $render = $view->field['name']->advancedRender($view->result[0]);
     $this->assertTrue(strpos($render, $username) !== FALSE, 'If link to user is checked the username should be part of the output.');
     $this->assertTrue(strpos($render, 'user/1') !== FALSE, 'If link to user is checked the link to the user should appear as well.');
     $view->field['name']->options['link_to_user'] = FALSE;
     $username = $view->result[0]->users_field_data_name = $this->randomMachineName();
     $view->result[0]->users_field_data_uid = 1;
     $render = $view->field['name']->advancedRender($view->result[0]);
     $this->assertIdentical($render, $username, 'If the user is not linked the username should be printed out for a normal user.');
     $view->result[0]->users_field_data_uid = 0;
     $anon_name = \Drupal::config('user.settings')->get('anonymous');
     $view->result[0]->users_field_data_name = '';
     $render = $view->field['name']->advancedRender($view->result[0]);
     $this->assertIdentical($render, $anon_name, 'For user0 it should use the default anonymous name by default.');
     $view->field['name']->options['overwrite_anonymous'] = TRUE;
     $anon_name = $view->field['name']->options['anonymous_text'] = $this->randomMachineName();
     $render = $view->field['name']->advancedRender($view->result[0]);
     $this->assertIdentical($render, $anon_name, 'For user0 it should use the configured anonymous text if overwrite_anonymous is checked.');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:26,代码来源:HandlerFieldUserNameTest.php

示例12: testStyleUI

 /**
  * Tests changing the style plugin and changing some options of a style.
  */
 public function testStyleUI()
 {
     $view_name = 'test_view';
     $view_edit_url = "admin/structure/views/view/{$view_name}/edit";
     $style_plugin_url = "admin/structure/views/nojs/display/{$view_name}/default/style";
     $style_options_url = "admin/structure/views/nojs/display/{$view_name}/default/style_options";
     $this->drupalGet($style_plugin_url);
     $this->assertFieldByName('style[type]', 'default', 'The default style plugin selected in the UI should be unformatted list.');
     $edit = array('style[type]' => 'test_style');
     $this->drupalPostForm(NULL, $edit, t('Apply'));
     $this->assertFieldByName('style_options[test_option]', NULL, 'Make sure the custom settings form from the test plugin appears.');
     $random_name = $this->randomMachineName();
     $edit = array('style_options[test_option]' => $random_name);
     $this->drupalPostForm(NULL, $edit, t('Apply'));
     $this->drupalGet($style_options_url);
     $this->assertFieldByName('style_options[test_option]', $random_name, 'Make sure the custom settings form field has the expected value stored.');
     $this->drupalPostForm($view_edit_url, array(), t('Save'));
     $this->assertLink(t('Test style plugin'), 0, 'Make sure the test style plugin is shown in the UI');
     $view = Views::getView($view_name);
     $view->initDisplay();
     $style = $view->display_handler->getOption('style');
     $this->assertEqual($style['type'], 'test_style', 'Make sure that the test_style got saved as used style plugin.');
     $this->assertEqual($style['options']['test_option'], $random_name, 'Make sure that the custom settings field got saved as expected.');
     // Test that fields are working correctly in the UI for style plugins when
     // a field row plguin is selected.
     $this->drupalPostForm("admin/structure/views/view/{$view_name}/edit", array(), 'Add Page');
     $this->drupalPostForm("admin/structure/views/nojs/display/{$view_name}/page_1/row", array('row[type]' => 'fields'), t('Apply'));
     // If fields are being used this text will not be shown.
     $this->assertNoText(t('The selected style or row format does not utilize fields.'));
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:33,代码来源:StyleUITest.php

示例13: preRenderViewElement

 /**
  * View element pre render callback.
  */
 public static function preRenderViewElement($element)
 {
     $element['#attributes']['class'][] = 'views-element-container';
     if (!isset($element['#view'])) {
         $view = Views::getView($element['#name']);
     } else {
         $view = $element['#view'];
     }
     if ($view && $view->access($element['#display_id'])) {
         if (!empty($element['#embed'])) {
             $element += $view->preview($element['#display_id'], $element['#arguments']);
         } else {
             // Add contextual links to the view. We need to attach them to the dummy
             // $view_array variable, since contextual_preprocess() requires that they
             // be attached to an array (not an object) in order to process them. For
             // our purposes, it doesn't matter what we attach them to, since once they
             // are processed by contextual_preprocess() they will appear in the
             // $title_suffix variable (which we will then render in
             // views-view.html.twig).
             $view->setDisplay($element['#display_id']);
             // Add the result of the executed view as a child element so any
             // #pre_render elements for the view will get processed. A #pre_render
             // element cannot be added to the main element as this is already inside
             // a #pre_render callback.
             $element['view_build'] = $view->executeDisplay($element['#display_id'], $element['#arguments']);
             if (isset($element['view_build']['#title'])) {
                 $element['#title'] =& $element['view_build']['#title'];
             }
             views_add_contextual_links($element, 'view', $view, $view->current_display);
         }
     }
     return $element;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:36,代码来源:View.php

示例14: preRenderViewElement

 /**
  * View element pre render callback.
  */
 public static function preRenderViewElement($element)
 {
     $element['#attributes']['class'][] = 'views-element-container';
     if (!isset($element['#view'])) {
         $view = Views::getView($element['#name']);
     } else {
         $view = $element['#view'];
     }
     if ($view && $view->access($element['#display_id'])) {
         if (!empty($element['embed'])) {
             $element += $view->preview($element['#display_id'], $element['#arguments']);
         } else {
             // Add contextual links to the view. We need to attach them to the dummy
             // $view_array variable, since contextual_preprocess() requires that they
             // be attached to an array (not an object) in order to process them. For
             // our purposes, it doesn't matter what we attach them to, since once they
             // are processed by contextual_preprocess() they will appear in the
             // $title_suffix variable (which we will then render in
             // views-view.html.twig).
             $view->setDisplay($element['#display_id']);
             $element += $view->executeDisplay($element['#display_id'], $element['#arguments']);
             views_add_contextual_links($element, 'view', $view, $view->current_display);
         }
     }
     return $element;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:29,代码来源:View.php

示例15: testRowUI

 /**
  * Tests changing the row plugin and changing some options of a row.
  */
 public function testRowUI()
 {
     $view_name = 'test_view';
     $view_edit_url = "admin/structure/views/view/{$view_name}/edit";
     $row_plugin_url = "admin/structure/views/nojs/display/{$view_name}/default/row";
     $row_options_url = "admin/structure/views/nojs/display/{$view_name}/default/row_options";
     $this->drupalGet($row_plugin_url);
     $this->assertFieldByName('row[type]', 'fields', 'The default row plugin selected in the UI should be fields.');
     $edit = array('row[type]' => 'test_row');
     $this->drupalPostForm(NULL, $edit, t('Apply'));
     $this->assertFieldByName('row_options[test_option]', NULL, 'Make sure the custom settings form from the test plugin appears.');
     $random_name = $this->randomMachineName();
     $edit = array('row_options[test_option]' => $random_name);
     $this->drupalPostForm(NULL, $edit, t('Apply'));
     $this->drupalGet($row_options_url);
     $this->assertFieldByName('row_options[test_option]', $random_name, 'Make sure the custom settings form field has the expected value stored.');
     $this->drupalPostForm($view_edit_url, array(), t('Save'));
     $this->assertLink(t('Test row plugin'), 0, 'Make sure the test row plugin is shown in the UI');
     $view = Views::getView($view_name);
     $view->initDisplay();
     $row = $view->display_handler->getOption('row');
     $this->assertEqual($row['type'], 'test_row', 'Make sure that the test_row got saved as used row plugin.');
     $this->assertEqual($row['options']['test_option'], $random_name, 'Make sure that the custom settings field got saved as expected.');
     // Change the row plugin to fields using ajax.
     $this->drupalPostAjaxForm($row_plugin_url, array('row[type]' => 'fields'), array('op' => 'Apply'), str_replace('/nojs/', '/ajax/', $row_plugin_url));
     $this->drupalPostAjaxForm(NULL, array(), array('op' => 'Apply'));
     $this->assertResponse(200);
     $this->assertFieldByName('row[type]', 'fields', 'Make sure that the fields got saved as used row plugin.');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:32,代码来源:RowUITest.php


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