Skip to content

Commit 328e14e

Browse files
committed
[general] Upgraded date time factory dueto testing issues (#311)
1 parent ea6869e commit 328e14e

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"contributte/monolog": "^0.5",
3939
"cweagans/composer-patches": "^1.7",
4040
"doctrine/orm": "2.15.*",
41-
"fastybird/datetime-factory": "^0.6",
41+
"fastybird/datetime-factory": "^0.7.1",
4242
"fastybird/metadata-library": "dev-main",
4343
"fastybird/simple-auth": "^0.14",
4444
"ipub/doctrine-timestampable": "^2.0",
@@ -47,6 +47,7 @@
4747
"nette/di": "^3.0",
4848
"nette/utils": "^4.0",
4949
"orisai/nette-object-mapper": "^0.1",
50+
"orisai/object-mapper": "^0.2",
5051
"react/event-loop": "^1.3",
5152
"sentry/sdk": "^3.1",
5253
"symfony/monolog-bridge": "^6.1",

src/Utilities/DateTimeProvider.php

+3-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use DateTimeInterface;
1919
use FastyBird\DateTimeFactory;
2020
use IPub\DoctrineTimestampable\Providers as DoctrineTimestampableProviders;
21-
use Nette\DI;
2221

2322
/**
2423
* Date provider for doctrine timestampable
@@ -31,24 +30,18 @@
3130
readonly class DateTimeProvider implements DoctrineTimestampableProviders\DateProvider
3231
{
3332

34-
public function __construct(private DI\Container $container)
33+
public function __construct(private DateTimeFactory\Clock $clock)
3534
{
3635
}
3736

38-
/**
39-
* @throws DI\MissingServiceException
40-
*/
4137
public function getDate(): DateTimeInterface
4238
{
43-
return $this->container->getByType(DateTimeFactory\Factory::class)->getNow();
39+
return $this->clock->getNow();
4440
}
4541

46-
/**
47-
* @throws DI\MissingServiceException
48-
*/
4942
public function getTimestamp(): int
5043
{
51-
return $this->container->getByType(DateTimeFactory\Factory::class)->getNow()->getTimestamp();
44+
return $this->clock->getNow()->getTimestamp();
5245
}
5346

5447
}

0 commit comments

Comments
 (0)