-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-30263: User date format don't apply to date fields in content ite…
…m update and preview (#26) * wip * refatoring * fixes cs * EZP-30263: User date format don't apply to date fields in content item update and preview * adds support for timestamp to twig filters * cs fix * adds option to overide timezone * fixws allowed datetime formats
- Loading branch information
Showing
10 changed files
with
260 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/lib/UserSetting/DateTimeFormat/FullDateFormatterFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace EzSystems\EzPlatformUser\UserSetting\DateTimeFormat; | ||
|
||
use EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer; | ||
use EzSystems\EzPlatformUser\UserSetting\UserSettingService; | ||
|
||
class FullDateFormatterFactory extends AbstractDateTimeFormatterFactory implements DateTimeFormatterFactoryInterface | ||
{ | ||
/** @var \EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer */ | ||
private $dateTimeFormatSerializer; | ||
|
||
/** | ||
* @param \EzSystems\EzPlatformUser\UserSetting\UserSettingService $userSettingService | ||
* @param \EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer $dateTimeFormatSerializer | ||
*/ | ||
public function __construct( | ||
UserSettingService $userSettingService, | ||
DateTimeFormatSerializer $dateTimeFormatSerializer | ||
) { | ||
parent::__construct($userSettingService); | ||
$this->dateTimeFormatSerializer = $dateTimeFormatSerializer; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getFormat(): string | ||
{ | ||
return (string)$this->dateTimeFormatSerializer->deserialize( | ||
$this->userSettingService->getUserSetting('full_datetime_format')->value | ||
)->getDateFormat(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/lib/UserSetting/DateTimeFormat/FullTimeFormatterFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace EzSystems\EzPlatformUser\UserSetting\DateTimeFormat; | ||
|
||
use EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer; | ||
use EzSystems\EzPlatformUser\UserSetting\UserSettingService; | ||
|
||
class FullTimeFormatterFactory extends AbstractDateTimeFormatterFactory implements DateTimeFormatterFactoryInterface | ||
{ | ||
/** @var \EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer */ | ||
private $dateTimeFormatSerializer; | ||
|
||
/** | ||
* @param \EzSystems\EzPlatformUser\UserSetting\UserSettingService $userSettingService | ||
* @param \EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer $dateTimeFormatSerializer | ||
*/ | ||
public function __construct( | ||
UserSettingService $userSettingService, | ||
DateTimeFormatSerializer $dateTimeFormatSerializer | ||
) { | ||
parent::__construct($userSettingService); | ||
$this->dateTimeFormatSerializer = $dateTimeFormatSerializer; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getFormat(): string | ||
{ | ||
return (string)$this->dateTimeFormatSerializer->deserialize( | ||
$this->userSettingService->getUserSetting('full_datetime_format')->value | ||
)->getTimeFormat(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/lib/UserSetting/DateTimeFormat/ShortDateFormatterFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace EzSystems\EzPlatformUser\UserSetting\DateTimeFormat; | ||
|
||
use EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer; | ||
use EzSystems\EzPlatformUser\UserSetting\UserSettingService; | ||
|
||
class ShortDateFormatterFactory extends AbstractDateTimeFormatterFactory implements DateTimeFormatterFactoryInterface | ||
{ | ||
/** @var \EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer */ | ||
private $dateTimeFormatSerializer; | ||
|
||
/** | ||
* @param \EzSystems\EzPlatformUser\UserSetting\UserSettingService $userSettingService | ||
* @param \EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer $dateTimeFormatSerializer | ||
*/ | ||
public function __construct( | ||
UserSettingService $userSettingService, | ||
DateTimeFormatSerializer $dateTimeFormatSerializer | ||
) { | ||
parent::__construct($userSettingService); | ||
$this->dateTimeFormatSerializer = $dateTimeFormatSerializer; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getFormat(): string | ||
{ | ||
return (string)$this->dateTimeFormatSerializer->deserialize( | ||
$this->userSettingService->getUserSetting('short_datetime_format')->value | ||
)->getDateFormat(); | ||
} | ||
} |
Oops, something went wrong.