Skip to content

Commit 40d7650

Browse files
committed
Allowing doctrine3
1 parent b9d8943 commit 40d7650

File tree

5 files changed

+42
-19
lines changed

5 files changed

+42
-19
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"symfony/config": "^5.4 || ^6.0 || ^7.0",
1919
"symfony/console": "^5.4 || ^6.0 || ^7.0",
2020
"symfony/process": "^5.4 || ^6.0 || ^7.0",
21-
"doctrine/orm": "^2.5.3"
21+
"doctrine/orm": "^2.5.3 || ^3.0"
2222
},
2323
"require-dev": {
2424
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",

src/Command/ScheduleSystemTasksCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Task\Scheduler\TaskSchedulerInterface;
1010
use Task\Storage\TaskExecutionRepositoryInterface;
1111
use Task\TaskBundle\Builder\TaskBuilder;
12+
use Task\TaskBundle\Entity\SystemTaskRepositoryInterface;
1213
use Task\TaskBundle\Entity\TaskRepository;
1314
use Task\TaskInterface;
1415
use Task\TaskStatus;
@@ -29,7 +30,7 @@ class ScheduleSystemTasksCommand extends Command
2930
private $scheduler;
3031

3132
/**
32-
* @var TaskRepository
33+
* @var SystemTaskRepositoryInterface
3334
*/
3435
private $taskRepository;
3536

@@ -42,14 +43,14 @@ class ScheduleSystemTasksCommand extends Command
4243
* @param string $name
4344
* @param array $systemTasks
4445
* @param TaskSchedulerInterface $scheduler
45-
* @param TaskRepository $taskRepository
46+
* @param SystemTaskRepositoryInterface $taskRepository
4647
* @param TaskExecutionRepositoryInterface $taskExecutionRepository
4748
*/
4849
public function __construct(
4950
$name,
5051
array $systemTasks,
5152
TaskSchedulerInterface $scheduler,
52-
TaskRepository $taskRepository,
53+
SystemTaskRepositoryInterface $taskRepository,
5354
TaskExecutionRepositoryInterface $taskExecutionRepository
5455
) {
5556
parent::__construct($name);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Task\TaskBundle\Entity;
6+
7+
use Task\Storage\TaskRepositoryInterface;
8+
9+
interface SystemTaskRepositoryInterface extends TaskRepositoryInterface
10+
{
11+
/**
12+
* Returns all system-task.
13+
*
14+
* @return TaskInterface[]
15+
*/
16+
public function findSystemTasks();
17+
18+
/**
19+
* Returns task identified by system-key.
20+
*
21+
* @param string $systemKey
22+
*
23+
* @return TaskInterface
24+
*/
25+
public function findBySystemKey($systemKey);
26+
}

src/Entity/TaskRepository.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111

1212
namespace Task\TaskBundle\Entity;
1313

14+
use DateTime;
1415
use Doctrine\ORM\EntityRepository;
1516
use Doctrine\ORM\NoResultException;
16-
use Task\Storage\TaskRepositoryInterface;
1717
use Task\TaskInterface;
1818

1919
/**
20-
* Repository for task.
20+
* Repository for tasks
21+
*
22+
* @extends EntityRepository<TaskInterface>
2123
*/
22-
class TaskRepository extends EntityRepository implements TaskRepositoryInterface
24+
class TaskRepository extends EntityRepository implements SystemTaskRepositoryInterface
2325
{
2426
/**
2527
* {@inheritdoc}
@@ -62,7 +64,7 @@ public function remove(TaskInterface $task)
6264
/**
6365
* {@inheritdoc}
6466
*/
65-
public function findAll($page = 1, $pageSize = null)
67+
public function findAll($page = 1, $pageSize = null): array
6668
{
6769
$query = $this->createQueryBuilder('t')
6870
->getQuery();
@@ -100,11 +102,7 @@ public function findEndBefore(\DateTime $dateTime)
100102
}
101103

102104
/**
103-
* Returns task identified by system-key.
104-
*
105-
* @param string $systemKey
106-
*
107-
* @return TaskInterface
105+
* {@inheritdoc}
108106
*/
109107
public function findBySystemKey($systemKey)
110108
{
@@ -120,9 +118,7 @@ public function findBySystemKey($systemKey)
120118
}
121119

122120
/**
123-
* Returns all system-task.
124-
*
125-
* @return TaskInterface[]
121+
* {@inheritdoc}
126122
*/
127123
public function findSystemTasks()
128124
{

tests/Unit/Command/ScheduleSystemTasksCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
use Task\Storage\TaskExecutionRepositoryInterface;
1414
use Task\TaskBundle\Builder\TaskBuilder;
1515
use Task\TaskBundle\Command\ScheduleSystemTasksCommand;
16+
use Task\TaskBundle\Entity\SystemTaskRepositoryInterface;
1617
use Task\TaskBundle\Entity\Task;
17-
use Task\TaskBundle\Entity\TaskRepository;
1818
use Task\TaskBundle\Tests\Functional\TestHandler;
1919
use Task\TaskStatus;
2020

@@ -28,7 +28,7 @@ class ScheduleSystemTasksCommandTest extends TestCase
2828
private $scheduler;
2929

3030
/**
31-
* @var TaskRepository
31+
* @var SystemTaskRepositoryInterface
3232
*/
3333
private $taskRepository;
3434

@@ -40,7 +40,7 @@ class ScheduleSystemTasksCommandTest extends TestCase
4040
protected function setUp(): void
4141
{
4242
$this->scheduler = $this->prophesize(TaskSchedulerInterface::class);
43-
$this->taskRepository = $this->prophesize(TaskRepository::class);
43+
$this->taskRepository = $this->prophesize(SystemTaskRepositoryInterface::class);
4444
$this->taskExecutionRepository = $this->prophesize(TaskExecutionRepositoryInterface::class);
4545
}
4646

0 commit comments

Comments
 (0)