-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[general] Use global date provider for doctrine timestampable (#310)
- Loading branch information
1 parent
25360b5
commit ea6869e
Showing
5 changed files
with
66 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
/** | ||
* TemplateFactory.php | ||
* | ||
* @license More in LICENSE.md | ||
* @copyright https://www.fastybird.com | ||
* @author Adam Kadlec <adam.kadlec@fastybird.com> | ||
* @package FastyBird:ApplicationLibrary! | ||
* @subpackage Utilities | ||
* @since 1.0.0 | ||
* | ||
* @date 29.08.24 | ||
*/ | ||
|
||
namespace FastyBird\Library\Application\Utilities; | ||
|
||
use DateTimeInterface; | ||
use FastyBird\DateTimeFactory; | ||
use IPub\DoctrineTimestampable\Providers as DoctrineTimestampableProviders; | ||
use Nette\DI; | ||
|
||
/** | ||
* Date provider for doctrine timestampable | ||
* | ||
* @package FastyBird:ApplicationLibrary! | ||
* @subpackage Subscribers | ||
* | ||
* @author Adam Kadlec <adam.kadlec@fastybird.com> | ||
*/ | ||
readonly class DateTimeProvider implements DoctrineTimestampableProviders\DateProvider | ||
{ | ||
|
||
public function __construct(private DI\Container $container) | ||
{ | ||
} | ||
|
||
/** | ||
* @throws DI\MissingServiceException | ||
*/ | ||
public function getDate(): DateTimeInterface | ||
{ | ||
return $this->container->getByType(DateTimeFactory\Factory::class)->getNow(); | ||
} | ||
|
||
/** | ||
* @throws DI\MissingServiceException | ||
*/ | ||
public function getTimestamp(): int | ||
{ | ||
return $this->container->getByType(DateTimeFactory\Factory::class)->getNow()->getTimestamp(); | ||
} | ||
|
||
} |