當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。