本文整理汇总了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());
}
示例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();
}
示例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();
}
示例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'));
}