Skip to content

Commit e4f3bf7

Browse files
authored
Merge pull request #84 from synolia/feature/SYLIUS-248-php-8-attributes
[DX] add PHP 8 ORM attributes
2 parents ea44054 + 90eaafe commit e4f3bf7

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

src/Entity/Command.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66

77
use Doctrine\Common\Collections\ArrayCollection;
88
use Doctrine\Common\Collections\Collection;
9+
use Doctrine\DBAL\Types\Types;
910
use Doctrine\ORM\Mapping as ORM;
11+
use Synolia\SyliusSchedulerCommandPlugin\Repository\CommandRepository;
1012

1113
/**
1214
* @ORM\Entity(repositoryClass="Synolia\SyliusSchedulerCommandPlugin\Repository\CommandRepository")
1315
* @ORM\Table("synolia_commands")
1416
*/
17+
#[ORM\Entity(repositoryClass: CommandRepository::class)]
18+
#[ORM\Table(name: 'synolia_commands')]
1519
class Command implements CommandInterface
1620
{
1721
/**
@@ -21,51 +25,65 @@ class Command implements CommandInterface
2125
* @ORM\GeneratedValue()
2226
* @ORM\Column(type="integer")
2327
*/
28+
#[ORM\Id]
29+
#[ORM\GeneratedValue]
30+
#[ORM\Column(type: Types::INTEGER)]
2431
private $id;
2532

2633
/** @ORM\Column(type="string") */
34+
#[ORM\Column(type: Types::STRING)]
2735
private string $name = '';
2836

2937
/** @ORM\Column(type="string") */
38+
#[ORM\Column(type: Types::STRING)]
3039
private string $command = '';
3140

3241
/** @ORM\Column(type="string", nullable=true) */
42+
#[ORM\Column(type: Types::STRING, nullable: true)]
3343
private ?string $arguments = null;
3444

3545
/**
3646
* @see https://abunchofutils.com/u/computing/cron-format-helper/
3747
*
3848
* @ORM\Column(type="string")
3949
*/
50+
#[ORM\Column(type: Types::STRING)]
4051
private string $cronExpression = '* * * * *';
4152

4253
/**
4354
* Log's file name prefix (without path), followed by a time stamp of the execution
4455
*
4556
* @ORM\Column(type="string", nullable=true)
4657
*/
58+
#[ORM\Column(type: Types::STRING, nullable: true)]
4759
private ?string $logFilePrefix = null;
4860

4961
/** @ORM\Column(type="integer") */
62+
#[ORM\Column(type: Types::INTEGER)]
5063
private int $priority = 0;
5164

5265
/**
5366
* If true, command will be execute next time regardless cron expression
5467
*
5568
* @ORM\Column(type="boolean")
5669
*/
70+
#[ORM\Column(type: Types::BOOLEAN)]
5771
private bool $executeImmediately = false;
5872

5973
/** @ORM\Column(type="boolean") */
74+
#[ORM\Column(type: Types::BOOLEAN)]
6075
private bool $enabled = true;
6176

6277
/** @ORM\Column(type="integer", nullable=true) */
78+
#[ORM\Column(type: Types::INTEGER, nullable: true)]
6379
private ?int $timeout = null;
6480

6581
/** @ORM\Column(type="integer", nullable=true) */
82+
#[ORM\Column(type: Types::INTEGER, nullable: true)]
6683
private ?int $idleTimeout = null;
6784

6885
/** @ORM\OneToMany(targetEntity="Synolia\SyliusSchedulerCommandPlugin\Entity\ScheduledCommandInterface", mappedBy="owner") */
86+
#[ORM\OneToMany(targetEntity: ScheduledCommandInterface::class, mappedBy: 'owner')]
6987
private Collection $scheduledCommands;
7088

7189
public function __construct()

src/Entity/ScheduledCommand.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44

55
namespace Synolia\SyliusSchedulerCommandPlugin\Entity;
66

7+
use Doctrine\DBAL\Types\Types;
78
use Doctrine\ORM\Mapping as ORM;
89
use Synolia\SyliusSchedulerCommandPlugin\Enum\ScheduledCommandStateEnum;
10+
use Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepository;
911

1012
/**
1113
* @ORM\Entity(repositoryClass="Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepository")
1214
* @ORM\Table("synolia_scheduled_commands")
1315
*/
16+
#[ORM\Entity(repositoryClass: ScheduledCommandRepository::class)]
17+
#[ORM\Table(name: 'synolia_scheduled_commands')]
1418
class ScheduledCommand implements ScheduledCommandInterface
1519
{
1620
/**
@@ -20,49 +24,65 @@ class ScheduledCommand implements ScheduledCommandInterface
2024
* @ORM\GeneratedValue()
2125
* @ORM\Column(type="integer")
2226
*/
27+
#[ORM\Id]
28+
#[ORM\GeneratedValue]
29+
#[ORM\Column(type: Types::INTEGER)]
2330
private $id;
2431

2532
/** @ORM\Column(type="string") */
33+
#[ORM\Column(type: Types::STRING)]
2634
private string $name = '';
2735

2836
/** @ORM\Column(type="string") */
37+
#[ORM\Column(type: Types::STRING)]
2938
private string $command = '';
3039

3140
/** @ORM\Column(type="string", nullable=true) */
41+
#[ORM\Column(type: Types::STRING, nullable: true)]
3242
private ?string $arguments = null;
3343

3444
/** @ORM\Column(name="executed_at", type="datetime", nullable=true) */
45+
#[ORM\Column(name: 'executed_at', type: Types::DATETIME_MUTABLE, nullable: true)]
3546
private ?\DateTime $executedAt = null;
3647

3748
/** @ORM\Column(type="integer", nullable=true) */
49+
#[ORM\Column(type: Types::INTEGER, nullable: true)]
3850
private ?int $lastReturnCode = null;
3951

4052
/**
4153
* Log's file name (without path)
4254
*
4355
* @ORM\Column(type="string", nullable=true)
4456
*/
57+
#[ORM\Column(type: Types::STRING, nullable: true)]
4558
private ?string $logFile = null;
4659

4760
/** @ORM\Column(type="datetime", nullable=true) */
61+
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
4862
private ?\DateTime $commandEndTime = null;
4963

5064
/** @ORM\Column(name="created_at", type="datetime", nullable=false) */
65+
#[ORM\Column(name: 'created_at', type: Types::DATETIME_MUTABLE, nullable: false)]
5166
private \DateTime $createdAt;
5267

5368
/** @ORM\Column(name="state", type="string") */
69+
#[ORM\Column(name: 'state', type: Types::STRING)]
5470
private string $state = ScheduledCommandStateEnum::WAITING;
5571

5672
/** @ORM\Column(type="integer", nullable=true) */
73+
#[ORM\Column(type: Types::INTEGER, nullable: true)]
5774
private ?int $timeout = null;
5875

5976
/** @ORM\Column(type="integer", nullable=true) */
77+
#[ORM\Column(type: Types::INTEGER, nullable: true)]
6078
private ?int $idleTimeout = null;
6179

6280
/**
6381
* @ORM\ManyToOne(targetEntity="Synolia\SyliusSchedulerCommandPlugin\Entity\CommandInterface", inversedBy="scheduledCommands")
6482
* @ORM\JoinColumn(name="owner_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
6583
*/
84+
#[ORM\ManyToOne(targetEntity: CommandInterface::class, inversedBy: 'scheduledCommands')]
85+
#[ORM\JoinColumn(name: 'owner_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
6686
private ?\Synolia\SyliusSchedulerCommandPlugin\Entity\CommandInterface $owner = null;
6787

6888
public function __construct()

0 commit comments

Comments
 (0)