當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::save方法代碼示例

本文整理匯總了PHP中Drupal\user\Entity\User::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::save方法的具體用法?PHP User::save怎麽用?PHP User::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\user\Entity\User的用法示例。


在下文中一共展示了User::save方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installSchema('system', 'sequences');
     $this->installEntitySchema('user');
     $this->manager = $this->container->get('plugin.manager.condition');
     // Set up the authenticated and anonymous roles.
     Role::create(array('id' => DRUPAL_ANONYMOUS_RID, 'label' => 'Anonymous user'))->save();
     Role::create(array('id' => DRUPAL_AUTHENTICATED_RID, 'label' => 'Authenticated user'))->save();
     // Create new role.
     $rid = strtolower($this->randomMachineName(8));
     $label = $this->randomString(8);
     $role = Role::create(array('id' => $rid, 'label' => $label));
     $role->save();
     $this->role = $role;
     // Setup an anonymous user for our tests.
     $this->anonymous = User::create(array('uid' => 0));
     $this->anonymous->save();
     // Loading the anonymous user adds the correct role.
     $this->anonymous = User::load($this->anonymous->id());
     // Setup an authenticated user for our tests.
     $this->authenticated = User::create(array('name' => $this->randomMachineName()));
     $this->authenticated->save();
     // Add the custom role.
     $this->authenticated->addRole($this->role->id());
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:29,代碼來源:UserRoleConditionTest.php

示例2: setUpFixtures

 /**
  * {@inheritdoc}
  */
 protected function setUpFixtures()
 {
     $this->installEntitySchema('user');
     $this->installConfig(array('user'));
     parent::setUpFixtures();
     // Create a record for uid 1.
     $this->rootUser = User::create(['name' => $this->randomMachineName()]);
     $this->rootUser->save();
     Views::viewsData()->clear();
 }
開發者ID:eigentor,項目名稱:tommiblog,代碼行數:13,代碼來源:RelationshipJoinTestBase.php

示例3: setUpFixtures

 /**
  * Overrides \Drupal\views\Tests\ViewUnitTestBase::setUpFixtures().
  */
 protected function setUpFixtures()
 {
     $this->installEntitySchema('user');
     $this->installConfig(array('user'));
     parent::setUpFixtures();
     // Create a record for uid 1.
     $this->installSchema('system', 'sequences');
     $this->root_user = entity_create('user', array('name' => $this->randomMachineName()));
     $this->root_user->save();
     Views::viewsData()->clear();
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:14,代碼來源:RelationshipJoinTestBase.php

示例4: setUp

 protected function setUp()
 {
     parent::setUp();
     // User create needs sequence table.
     $this->installSchema('system', array('sequences'));
     // Create a test user to use as the entity owner.
     $this->user = \Drupal::entityManager()->getStorage('user')->create(['name' => 'serialization_test_user', 'mail' => 'foo@example.com', 'pass' => '123456']);
     $this->user->save();
     // Create a test entity to serialize.
     $this->values = array('name' => $this->randomMachineName(), 'user_id' => $this->user->id(), 'field_test_text' => array('value' => $this->randomMachineName(), 'format' => 'full_html'));
     $this->entity = entity_create('entity_test_mulrev', $this->values);
     $this->entity->save();
     $this->serializer = $this->container->get('serializer');
     $this->installConfig(array('field'));
 }
開發者ID:HakS,項目名稱:drupal8_training,代碼行數:15,代碼來源:EntitySerializationTest.php


注:本文中的Drupal\user\Entity\User::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。