当前位置: 首页>>代码示例>>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;未经允许,请勿转载。