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


PHP Views::executableFactory方法代码示例

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


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

示例1: testViewAdd

 /**
  * Tests creating a node revision view.
  */
 public function testViewAdd()
 {
     $this->drupalCreateContentType(array('type' => 'article'));
     // Create two nodes with two revision.
     $node_storage = \Drupal::entityManager()->getStorage('node');
     /** @var \Drupal\node\NodeInterface $node */
     $node = $node_storage->create(array('title' => $this->randomString(), 'type' => 'article', 'created' => REQUEST_TIME + 40));
     $node->save();
     $node = $node->createDuplicate();
     $node->setNewRevision();
     $node->created->value = REQUEST_TIME + 20;
     $node->save();
     $node = $node_storage->create(array('title' => $this->randomString(), 'type' => 'article', 'created' => REQUEST_TIME + 30));
     $node->save();
     $node = $node->createDuplicate();
     $node->setNewRevision();
     $node->created->value = REQUEST_TIME + 10;
     $node->save();
     $view = array();
     $view['label'] = $this->randomMachineName(16);
     $view['id'] = strtolower($this->randomMachineName(16));
     $view['description'] = $this->randomMachineName(16);
     $view['page[create]'] = FALSE;
     $view['show[wizard_key]'] = 'node_revision';
     $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
     $view_storage_controller = \Drupal::entityManager()->getStorage('view');
     /** @var \Drupal\views\Entity\View $view */
     $view = $view_storage_controller->load($view['id']);
     $this->assertEqual($view->get('base_table'), 'node_field_revision');
     $executable = Views::executableFactory()->get($view);
     $this->executeView($executable);
     $this->assertIdenticalResultset($executable, array(array('vid' => 1), array('vid' => 3), array('vid' => 2), array('vid' => 4)), array('vid' => 'vid'));
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:36,代码来源:NodeRevisionWizardTest.php

示例2: testAccessRole

 /**
  * Tests role access plugin.
  */
 function testAccessRole()
 {
     /** @var \Drupal\views\ViewStorageInterface $view */
     $view = \Drupal::entityManager()->getStorage('view')->load('test_access_role');
     $display =& $view->getDisplay('default');
     $display['display_options']['access']['options']['role'] = array($this->normalRole => $this->normalRole);
     $view->save();
     $executable = Views::executableFactory()->get($view);
     $executable->setDisplay('page_1');
     $access_plugin = $executable->display_handler->getPlugin('access');
     $this->assertTrue($access_plugin instanceof Role, 'Make sure the right class got instantiated.');
     // Test the access() method on the access plugin.
     $this->assertTrue($executable->display_handler->access($this->adminUser), 'Admin-Account should be able to access the view everytime');
     $this->assertFalse($executable->display_handler->access($this->webUser));
     $this->assertTrue($executable->display_handler->access($this->normalUser));
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('test-role');
     $this->assertResponse(200);
     $this->drupalLogin($this->webUser);
     $this->drupalGet('test-role');
     $this->assertResponse(403);
     $this->drupalLogin($this->normalUser);
     $this->drupalGet('test-role');
     $this->assertResponse(200);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:28,代码来源:AccessRoleTest.php

示例3: testAccessRole

 /**
  * Tests role access plugin.
  */
 function testAccessRole()
 {
     /** @var \Drupal\views\ViewEntityInterface $view */
     $view = \Drupal::entityManager()->getStorage('view')->load('test_access_role');
     $display =& $view->getDisplay('default');
     $display['display_options']['access']['options']['role'] = array($this->normalRole => $this->normalRole);
     $view->save();
     $this->container->get('router.builder')->rebuildIfNeeded();
     $expected = ['config' => ['user.role.' . $this->normalRole], 'module' => ['user']];
     $this->assertIdentical($expected, $view->calculateDependencies()->getDependencies());
     $executable = Views::executableFactory()->get($view);
     $executable->setDisplay('page_1');
     $access_plugin = $executable->display_handler->getPlugin('access');
     $this->assertTrue($access_plugin instanceof Role, 'Make sure the right class got instantiated.');
     // Test the access() method on the access plugin.
     $this->assertFalse($executable->display_handler->access($this->webUser));
     $this->assertTrue($executable->display_handler->access($this->normalUser));
     $this->drupalLogin($this->webUser);
     $this->drupalGet('test-role');
     $this->assertResponse(403);
     $this->assertCacheContext('user.roles');
     $this->drupalLogin($this->normalUser);
     $this->drupalGet('test-role');
     $this->assertResponse(200);
     $this->assertCacheContext('user.roles');
     // Test allowing multiple roles.
     $view = Views::getView('test_access_role')->storage;
     $display =& $view->getDisplay('default');
     $display['display_options']['access']['options']['role'] = array($this->normalRole => $this->normalRole, 'anonymous' => 'anonymous');
     $view->save();
     $this->container->get('router.builder')->rebuildIfNeeded();
     // Ensure that the list of roles is sorted correctly, if the generated role
     // ID comes before 'anonymous', see https://www.drupal.org/node/2398259.
     $roles = ['user.role.anonymous', 'user.role.' . $this->normalRole];
     sort($roles);
     $expected = ['config' => $roles, 'module' => ['user']];
     $this->assertIdentical($expected, $view->calculateDependencies()->getDependencies());
     $this->drupalLogin($this->webUser);
     $this->drupalGet('test-role');
     $this->assertResponse(403);
     $this->assertCacheContext('user.roles');
     $this->drupalLogout();
     $this->drupalGet('test-role');
     $this->assertResponse(200);
     $this->assertCacheContext('user.roles');
     $this->drupalLogin($this->normalUser);
     $this->drupalGet('test-role');
     $this->assertResponse(200);
     $this->assertCacheContext('user.roles');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:53,代码来源:AccessRoleTest.php

示例4: attachDisplays

 /**
  * Run attachment displays for the view.
  */
 public function attachDisplays()
 {
     if (!empty($this->is_attachment)) {
         return;
     }
     if (!$this->display_handler->acceptAttachments()) {
         return;
     }
     $this->is_attachment = TRUE;
     // Find out which other displays attach to the current one.
     foreach ($this->display_handler->getAttachedDisplays() as $id) {
         $display_handler = $this->displayHandlers->get($id);
         // Only attach enabled attachments.
         if ($display_handler->isEnabled()) {
             $cloned_view = Views::executableFactory()->get($this->storage);
             $display_handler->attachTo($cloned_view, $this->current_display, $this->element);
         }
     }
     $this->is_attachment = FALSE;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:23,代码来源:ViewExecutable.php

示例5: __construct

 /**
  * Constructs a View UI object.
  *
  * @param \Drupal\views\ViewStorageInterface $storage
  *   The View storage object to wrap.
  */
 public function __construct(ViewStorageInterface $storage, ViewExecutable $executable = NULL)
 {
     $this->entityType = 'view';
     $this->storage = $storage;
     if (!isset($executable)) {
         $executable = Views::executableFactory()->get($this);
     }
     $this->executable = $executable;
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:15,代码来源:ViewUI.php

示例6: getExecutable

 /**
  * Gets an executable instance for this view.
  *
  * @return \Drupal\views\ViewExecutable
  *   A view executable instance.
  */
 public function getExecutable()
 {
     // Ensure that an executable View is available.
     if (!isset($this->executable)) {
         $this->executable = Views::executableFactory()->get($this);
     }
     return $this->executable;
 }
开发者ID:shumer,项目名称:blog,代码行数:14,代码来源:View.php

示例7: preDelete

 /**
  * {@inheritdoc}
  */
 public static function preDelete(EntityStorageInterface $storage, array $entities)
 {
     parent::preDelete($storage, $entities);
     // Call the remove() hook on the individual displays.
     /** @var \Drupal\views\ViewEntityInterface $entity */
     foreach ($entities as $entity) {
         $executable = Views::executableFactory()->get($entity);
         foreach ($entity->get('display') as $display_id => $display) {
             $executable->setDisplay($display_id);
             $executable->getDisplay()->remove();
         }
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:16,代码来源:View.php


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