本文整理汇总了PHP中Drupal\user\Entity\User::getAllowedTimezones方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getAllowedTimezones方法的具体用法?PHP User::getAllowedTimezones怎么用?PHP User::getAllowedTimezones使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\user\Entity\User
的用法示例。
在下文中一共展示了User::getAllowedTimezones方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('entity_test');
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test_rev');
// Bypass any field access.
$this->adminUser = User::create(['name' => $this->randomString()]);
$this->adminUser->save();
$this->container->get('current_user')->setAccount($this->adminUser);
$this->testUsers = [];
for ($i = 0; $i < 5; $i++) {
$this->testUsers[$i] = User::create(['name' => 'test ' . $i, 'timezone' => User::getAllowedTimezones()[$i]]);
$this->testUsers[$i]->save();
}
// Setup a field storage and field, but also change the views data for the
// entity_test entity type.
$field_storage = FieldStorageConfig::create(['field_name' => 'field_test', 'type' => 'integer', 'entity_type' => 'entity_test']);
$field_storage->save();
$field = FieldConfig::create(['field_name' => 'field_test', 'entity_type' => 'entity_test', 'bundle' => 'entity_test']);
$field->save();
$field_storage_multiple = FieldStorageConfig::create(['field_name' => 'field_test_multiple', 'type' => 'integer', 'entity_type' => 'entity_test', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED]);
$field_storage_multiple->save();
$field_multiple = FieldConfig::create(['field_name' => 'field_test_multiple', 'entity_type' => 'entity_test', 'bundle' => 'entity_test']);
$field_multiple->save();
$random_number = (string) 30856;
$random_number_multiple = (string) 1370359990;
for ($i = 0; $i < 5; $i++) {
$this->entities[$i] = $entity = EntityTest::create(['bundle' => 'entity_test', 'name' => 'test ' . $i, 'field_test' => $random_number[$i], 'field_test_multiple' => [$random_number_multiple[$i * 2], $random_number_multiple[$i * 2 + 1]], 'user_id' => $this->testUsers[$i]->id()]);
$entity->save();
}
// Setup some test data for entities with revisions.
// We are testing both base field revisions and field config revisions.
$field_storage = FieldStorageConfig::create(['field_name' => 'field_test', 'type' => 'integer', 'entity_type' => 'entity_test_rev']);
$field_storage->save();
$field = FieldConfig::create(['field_name' => 'field_test', 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev']);
$field->save();
$field_storage_multiple = FieldStorageConfig::create(['field_name' => 'field_test_multiple', 'type' => 'integer', 'entity_type' => 'entity_test_rev', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED]);
$field_storage_multiple->save();
$field_multiple = FieldConfig::create(['field_name' => 'field_test_multiple', 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev']);
$field_multiple->save();
$this->entityRevision = [];
$this->entityRevision[0] = $entity = EntityTestRev::create(['name' => 'base value', 'field_test' => 1, 'field_test_multiple' => [1, 3, 7], 'user_id' => $this->testUsers[0]->id()]);
$entity->save();
$original_entity = clone $entity;
$entity = clone $original_entity;
$entity->setNewRevision(TRUE);
$entity->name->value = 'revision value1';
$entity->field_test->value = 2;
$entity->field_test_multiple[0]->value = 0;
$entity->field_test_multiple[1]->value = 3;
$entity->field_test_multiple[2]->value = 5;
$entity->user_id->target_id = $this->testUsers[1]->id();
$entity->save();
$this->entityRevision[1] = $entity;
$entity = clone $original_entity;
$entity->setNewRevision(TRUE);
$entity->name->value = 'revision value2';
$entity->field_test->value = 3;
$entity->field_test_multiple[0]->value = 9;
$entity->field_test_multiple[1]->value = 9;
$entity->field_test_multiple[2]->value = 9;
$entity->user_id->target_id = $this->testUsers[2]->id();
$entity->save();
$this->entityRevision[2] = $entity;
$this->entityRevision[3] = $entity = EntityTestRev::create(['name' => 'next entity value', 'field_test' => 4, 'field_test_multiple' => [2, 9, 9], 'user_id' => $this->testUsers[3]->id()]);
$entity->save();
\Drupal::state()->set('entity_test.views_data', ['entity_test' => ['id' => ['field' => ['id' => 'field']]], 'entity_test_rev_revision' => ['id' => ['field' => ['id' => 'field']]]]);
Views::viewsData()->clear();
}