add a i18n api field for the users "now" datetime (#2007)
This commit is contained in:
@@ -81,6 +81,7 @@ final class ConfigurationController extends BaseApiController
|
|||||||
->setDuration($this->formats->getDurationFormat($locale))
|
->setDuration($this->formats->getDurationFormat($locale))
|
||||||
->setTime($this->formats->getTimeFormat($locale))
|
->setTime($this->formats->getTimeFormat($locale))
|
||||||
->setIs24hours($this->formats->isTwentyFourHours($locale))
|
->setIs24hours($this->formats->isTwentyFourHours($locale))
|
||||||
|
->setNow($this->getDateTimeFactory()->createDateTime())
|
||||||
;
|
;
|
||||||
|
|
||||||
$view = new View($model, 200);
|
$view = new View($model, 200);
|
||||||
|
|||||||
@@ -88,6 +88,23 @@ final class I18nConfig
|
|||||||
* @Serializer\Type(name="boolean")
|
* @Serializer\Type(name="boolean")
|
||||||
*/
|
*/
|
||||||
private $is24hours = true;
|
private $is24hours = true;
|
||||||
|
/**
|
||||||
|
* The current time of the user
|
||||||
|
*
|
||||||
|
* @var \DateTime
|
||||||
|
*
|
||||||
|
* @Serializer\Expose()
|
||||||
|
* @Serializer\Groups({"Default"})
|
||||||
|
* @Serializer\Type(name="DateTime")
|
||||||
|
*/
|
||||||
|
private $now;
|
||||||
|
|
||||||
|
public function setNow(\DateTime $now): I18nConfig
|
||||||
|
{
|
||||||
|
$this->now = $now;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setFormDateTime(string $formDateTime): I18nConfig
|
public function setFormDateTime(string $formDateTime): I18nConfig
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ class ConfigurationControllerTest extends APIControllerBaseTest
|
|||||||
|
|
||||||
$this->assertIsArray($result);
|
$this->assertIsArray($result);
|
||||||
$this->assertNotEmpty($result);
|
$this->assertNotEmpty($result);
|
||||||
$this->assertEquals(7, \count($result));
|
$this->assertEquals(8, \count($result));
|
||||||
$this->assertI18nStructure($result);
|
$this->assertI18nStructure($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function assertI18nStructure(array $result)
|
protected function assertI18nStructure(array $result)
|
||||||
{
|
{
|
||||||
$expectedKeys = ['date', 'dateTime', 'duration', 'formDate', 'formDateTime', 'is24hours', 'time'];
|
$expectedKeys = ['date', 'dateTime', 'duration', 'formDate', 'formDateTime', 'is24hours', 'time', 'now'];
|
||||||
$actual = array_keys($result);
|
$actual = array_keys($result);
|
||||||
sort($actual);
|
sort($actual);
|
||||||
sort($expectedKeys);
|
sort($expectedKeys);
|
||||||
|
|||||||
Reference in New Issue
Block a user