Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing doctrine3 #56

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"symfony/config": "^5.4 || ^6.0 || ^7.0",
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/process": "^5.4 || ^6.0 || ^7.0",
"doctrine/orm": "^2.5.3"
"doctrine/orm": "^2.5.3 || ^3.0"
},
"require-dev": {
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
Expand Down
7 changes: 4 additions & 3 deletions src/Command/ScheduleSystemTasksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Task\Scheduler\TaskSchedulerInterface;
use Task\Storage\TaskExecutionRepositoryInterface;
use Task\TaskBundle\Builder\TaskBuilder;
use Task\TaskBundle\Entity\SystemTaskRepositoryInterface;
use Task\TaskBundle\Entity\TaskRepository;
use Task\TaskInterface;
use Task\TaskStatus;
Expand All @@ -29,7 +30,7 @@ class ScheduleSystemTasksCommand extends Command
private $scheduler;

/**
* @var TaskRepository
* @var SystemTaskRepositoryInterface
*/
private $taskRepository;

Expand All @@ -42,14 +43,14 @@ class ScheduleSystemTasksCommand extends Command
* @param string $name
* @param array $systemTasks
* @param TaskSchedulerInterface $scheduler
* @param TaskRepository $taskRepository
* @param SystemTaskRepositoryInterface $taskRepository
* @param TaskExecutionRepositoryInterface $taskExecutionRepository
*/
public function __construct(
$name,
array $systemTasks,
TaskSchedulerInterface $scheduler,
TaskRepository $taskRepository,
SystemTaskRepositoryInterface $taskRepository,
TaskExecutionRepositoryInterface $taskExecutionRepository
) {
parent::__construct($name);
Expand Down
26 changes: 26 additions & 0 deletions src/Entity/SystemTaskRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace Task\TaskBundle\Entity;

use Task\Storage\TaskRepositoryInterface;

interface SystemTaskRepositoryInterface extends TaskRepositoryInterface
{
/**
* Returns all system-task.
*
* @return TaskInterface[]
*/
public function findSystemTasks();

/**
* Returns task identified by system-key.
*
* @param string $systemKey
*
* @return TaskInterface
*/
public function findBySystemKey($systemKey);
}
20 changes: 8 additions & 12 deletions src/Entity/TaskRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@

namespace Task\TaskBundle\Entity;

use DateTime;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NoResultException;
use Task\Storage\TaskRepositoryInterface;
use Task\TaskInterface;

/**
* Repository for task.
* Repository for tasks
*
* @extends EntityRepository<TaskInterface>
*/
class TaskRepository extends EntityRepository implements TaskRepositoryInterface
class TaskRepository extends EntityRepository implements SystemTaskRepositoryInterface
{
/**
* {@inheritdoc}
Expand Down Expand Up @@ -62,7 +64,7 @@ public function remove(TaskInterface $task)
/**
* {@inheritdoc}
*/
public function findAll($page = 1, $pageSize = null)
public function findAll($page = 1, $pageSize = null): array
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is required by doctrine 3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend not "overriding" this method in the first place as it has different parameters in the default implementation and could possibly be very confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mamazu yeah 😂 after a few year i would not do that again. Maybe i will rework the repository in the future! for now the change is good.

{
$query = $this->createQueryBuilder('t')
->getQuery();
Expand Down Expand Up @@ -100,11 +102,7 @@ public function findEndBefore(\DateTime $dateTime)
}

/**
* Returns task identified by system-key.
*
* @param string $systemKey
*
* @return TaskInterface
* {@inheritdoc}
*/
public function findBySystemKey($systemKey)
{
Expand All @@ -120,9 +118,7 @@ public function findBySystemKey($systemKey)
}

/**
* Returns all system-task.
*
* @return TaskInterface[]
* {@inheritdoc}
*/
public function findSystemTasks()
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Command/ScheduleSystemTasksCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use Task\Storage\TaskExecutionRepositoryInterface;
use Task\TaskBundle\Builder\TaskBuilder;
use Task\TaskBundle\Command\ScheduleSystemTasksCommand;
use Task\TaskBundle\Entity\SystemTaskRepositoryInterface;
use Task\TaskBundle\Entity\Task;
use Task\TaskBundle\Entity\TaskRepository;
use Task\TaskBundle\Tests\Functional\TestHandler;
use Task\TaskStatus;

Expand All @@ -28,7 +28,7 @@ class ScheduleSystemTasksCommandTest extends TestCase
private $scheduler;

/**
* @var TaskRepository
* @var SystemTaskRepositoryInterface
*/
private $taskRepository;

Expand All @@ -40,7 +40,7 @@ class ScheduleSystemTasksCommandTest extends TestCase
protected function setUp(): void
{
$this->scheduler = $this->prophesize(TaskSchedulerInterface::class);
$this->taskRepository = $this->prophesize(TaskRepository::class);
$this->taskRepository = $this->prophesize(SystemTaskRepositoryInterface::class);
$this->taskExecutionRepository = $this->prophesize(TaskExecutionRepositoryInterface::class);
}

Expand Down