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


PHP node_access_test_add_field函数代码示例

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


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

示例1: setUp

 function setUp()
 {
     parent::setUp();
     node_access_rebuild();
     node_access_test_add_field(entity_load('node_type', 'forum'));
     \Drupal::state()->set('node_access_test.private', TRUE);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:7,代码来源:ForumNodeAccessTest.php

示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     node_access_test_add_field(NodeType::load('article'));
     node_access_rebuild();
     \Drupal::state()->set('node_access_test.private', TRUE);
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:7,代码来源:NodeAccessBaseTableTest.php

示例3: setUp

 public function setUp()
 {
     parent::setUp();
     node_access_rebuild();
     $this->drupalCreateContentType(array('type' => 'page'));
     node_access_test_add_field(entity_load('node_type', 'page'));
     $this->container->get('comment.manager')->addDefaultField('node', 'page', 'comment', CommentItemInterface::OPEN);
     \Drupal::state()->set('node_access_test.private', TRUE);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:9,代码来源:TrackerNodeAccessTest.php

示例4: setUp

 protected function setUp()
 {
     parent::setUp();
     node_access_rebuild();
     $this->drupalCreateContentType(array('type' => 'page'));
     node_access_test_add_field(NodeType::load('page'));
     $this->addDefaultCommentField('node', 'page', 'comment', CommentItemInterface::OPEN);
     \Drupal::state()->set('node_access_test.private', TRUE);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:9,代码来源:TrackerNodeAccessTest.php

示例5: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Create Article node type.
     $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
     $this->accessHandler = \Drupal::entityManager()->getAccessControlHandler('node');
     node_access_test_add_field(NodeType::load('article'));
     // After enabling a node access module, the access table has to be rebuild.
     node_access_rebuild();
     // Enable the private node feature of the node_access_test module.
     \Drupal::state()->set('node_access_test.private', TRUE);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:15,代码来源:BulkFormAccessTest.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     node_access_test_add_field(NodeType::load('page'));
     // After enabling a node access module, the access table has to be rebuild.
     node_access_rebuild();
     // Enable the private node feature of the node_access_test module.
     \Drupal::state()->set('node_access_test.private', TRUE);
     // Add Hungarian, Catalan and Croatian.
     ConfigurableLanguage::createFromLangcode('hu')->save();
     ConfigurableLanguage::createFromLangcode('ca')->save();
     ConfigurableLanguage::createFromLangcode('hr')->save();
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:13,代码来源:NodeAccessLanguageTest.php

示例7: setUp

 function setUp()
 {
     parent::setUp();
     node_access_test_add_field(entity_load('node_type', 'page'));
     // After enabling a node access module, the access table has to be rebuild.
     node_access_rebuild();
     // Enable the private node feature of the node_access_test module.
     \Drupal::state()->set('node_access_test.private', TRUE);
     // Add Hungarian and Catalan.
     $language = new Language(array('id' => 'hu'));
     language_save($language);
     $language = new Language(array('id' => 'ca'));
     language_save($language);
     $language = new Language(array('id' => 'hr'));
     language_save($language);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:16,代码来源:NodeAccessLanguageTest.php

示例8: testNodeAccessRebuildNodeGrants

 /**
  * Tests rebuilding the node access permissions table with content.
  */
 public function testNodeAccessRebuildNodeGrants()
 {
     \Drupal::service('module_installer')->install(['node_access_test']);
     \Drupal::state()->set('node_access_test.private', TRUE);
     node_access_test_add_field(NodeType::load('page'));
     $this->resetAll();
     // Create 30 nodes so that _node_access_rebuild_batch_operation() has to run
     // more than once.
     for ($i = 0; $i < 30; $i++) {
         $nodes[] = $this->drupalCreateNode(array('uid' => $this->webUser->id(), 'private' => [['value' => 1]]));
     }
     /** @var \Drupal\node\NodeGrantDatabaseStorageInterface $grant_storage */
     $grant_storage = \Drupal::service('node.grant_storage');
     // Default realm access and node records are present.
     foreach ($nodes as $node) {
         $this->assertTrue($node->private->value);
         $this->assertTrue($grant_storage->access($node, 'view', $this->webUser)->isAllowed(), 'Prior to rebuilding node access the grant storage returns allowed for the node author.');
         $this->assertTrue($grant_storage->access($node, 'view', $this->adminUser)->isAllowed(), 'Prior to rebuilding node access the grant storage returns allowed for the admin user.');
     }
     $this->assertEqual(1, \Drupal::service('node.grant_storage')->checkAll($this->webUser), 'There is an all realm access record');
     $this->assertTrue(\Drupal::state()->get('node.node_access_needs_rebuild'), 'Node access permissions need to be rebuilt');
     // Rebuild permissions.
     $this->drupalGet('admin/reports/status');
     $this->clickLink(t('Rebuild permissions'));
     $this->drupalPostForm(NULL, array(), t('Rebuild permissions'));
     $this->assertText(t('The content access permissions have been rebuilt.'));
     // Test if the rebuild by user that cannot bypass node access and does not
     // have access to the nodes has been successful.
     $this->assertFalse($this->adminUser->hasPermission('bypass node access'));
     $this->assertNull(\Drupal::state()->get('node.node_access_needs_rebuild'), 'Node access permissions have been rebuilt');
     foreach ($nodes as $node) {
         $this->assertTrue($grant_storage->access($node, 'view', $this->webUser)->isAllowed(), 'After rebuilding node access the grant storage returns allowed for the node author.');
         $this->assertFalse($grant_storage->access($node, 'view', $this->adminUser)->isForbidden(), 'After rebuilding node access the grant storage returns forbidden for the admin user.');
     }
     $this->assertFalse(\Drupal::service('node.grant_storage')->checkAll($this->webUser), 'There is no all realm access record');
     // Test an anonymous node access rebuild from code.
     $this->drupalLogout();
     node_access_rebuild();
     foreach ($nodes as $node) {
         $this->assertTrue($grant_storage->access($node, 'view', $this->webUser)->isAllowed(), 'After rebuilding node access the grant storage returns allowed for the node author.');
         $this->assertFalse($grant_storage->access($node, 'view', $this->adminUser)->isForbidden(), 'After rebuilding node access the grant storage returns forbidden for the admin user.');
     }
     $this->assertFalse(\Drupal::service('node.grant_storage')->checkAll($this->webUser), 'There is no all realm access record');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:47,代码来源:NodeAccessRebuildNodeGrantsTest.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     node_access_test_add_field(NodeType::load('page'));
     // Create the 'private' field, which allows the node to be marked as private
     // (restricted access) in a given translation.
     $field_storage = entity_create('field_storage_config', array('field_name' => 'field_private', 'entity_type' => 'node', 'type' => 'boolean', 'cardinality' => 1));
     $field_storage->save();
     entity_create('field_config', array('field_storage' => $field_storage, 'bundle' => 'page', 'widget' => array('type' => 'options_buttons'), 'settings' => array('on_label' => 'Private', 'off_label' => 'Not private')))->save();
     // After enabling a node access module, the access table has to be rebuild.
     node_access_rebuild();
     // Add Hungarian and Catalan.
     ConfigurableLanguage::createFromLangcode('hu')->save();
     ConfigurableLanguage::createFromLangcode('ca')->save();
     // Create a normal authenticated user.
     $this->webUser = $this->drupalCreateUser(array('access content'));
     // Load the user 1 user for later use as an admin user with permission to
     // see everything.
     $this->adminUser = User::load(1);
     // The node_access_test_language module allows individual translations of a
     // node to be marked private (not viewable by normal users), and the
     // node_access_test module allows whole nodes to be marked private. (In a
     // real-world implementation, hook_node_access_records_alter() might be
     // implemented by one or both modules to enforce that private nodes or
     // translations are always private, but we want to test the default,
     // additive behavior of node access).
     // Create six Hungarian nodes with Catalan translations:
     // 1. One public with neither language marked as private.
     // 2. One private with neither language marked as private.
     // 3. One public with only the Hungarian translation private.
     // 4. One public with only the Catalan translation private.
     // 5. One public with both the Hungarian and Catalan translations private.
     // 6. One private with both the Hungarian and Catalan translations private.
     $this->nodes['public_both_public'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 0)), 'private' => FALSE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 0;
     $node->save();
     $this->nodes['private_both_public'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 0)), 'private' => TRUE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 0;
     $node->save();
     $this->nodes['public_hu_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 1)), 'private' => FALSE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 0;
     $node->save();
     $this->nodes['public_ca_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 0)), 'private' => FALSE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 1;
     $node->save();
     $this->nodes['public_both_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 1)), 'private' => FALSE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 1;
     $node->save();
     $this->nodes['private_both_private'] = $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'field_private' => array(array('value' => 1)), 'private' => TRUE));
     $translation = $node->addTranslation('ca');
     $translation->title->value = $this->randomString();
     $translation->field_private->value = 1;
     $node->save();
     $this->nodes['public_no_language_private'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 1)), 'private' => FALSE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->nodes['public_no_language_public'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 0)), 'private' => FALSE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->nodes['private_no_language_private'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 1)), 'private' => TRUE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->nodes['private_no_language_public'] = $this->drupalCreateNode(array('field_private' => array(array('value' => 1)), 'private' => TRUE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:68,代码来源:NodeAccessLanguageAwareCombinationTest.php


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