Skip to content

Commit

Permalink
Add annotations for orm mapping in addition to attributes to be compa…
Browse files Browse the repository at this point in the history
…tible with both implementation
  • Loading branch information
Louis Fortunier committed Mar 28, 2024
1 parent e9651f8 commit 43dc5f4
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
CHANGELOG
===================
## v2.1.1 - (2024-03-28)

### Added
- Add annotations for orm mapping in addition to attributes to be compatible with both implementation

### Fixed
- `BatchLog::date` type to `DATETIME_MUTABLE` (type error introduce in update v2.0.0)
- `UserTrait::lastLogin` type to `DATETIME_MUTABLE` (type error introduce in update v2.0.0)

## v2.1.0 - (2024-03-17)

### Uprade guide
Expand Down
31 changes: 30 additions & 1 deletion src/Entity/Log/BatchLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,63 @@

/**
* @author Louis Fortunier <[email protected]>
*
* @ORM\Table(name="batch_log")
* @ORM\Entity(repositoryClass="Smart\SonataBundle\Repository\Log\BatchLogRepository")
*/
#[ORM\Table(name: 'batch_log')]
#[ORM\Entity(repositoryClass: BatchLogRepository::class)]
class BatchLog
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;

#[ORM\Column(type: Types::DATE_MUTABLE)]
/**
* @ORM\Column(type=Types::DATETIME_MUTABLE)
*/
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTime $date = null;

/**
* @ORM\Column(length=255)
*/
#[ORM\Column(length: 255)]
private ?string $context = null;

/**
* @ORM\Column(length=255)
*/
#[ORM\Column(length: 255)]
private ?string $name = null;

/**
* @ORM\Column(type="text", nullable=true)
*/
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $summary = null;

/**
* @ORM\Column(type="text", nullable=true)
*/
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $comment = null;

/**
* @ORM\Column(nullable=true)
*/
#[ORM\Column(nullable: true)]
private ?array $data = null;

/**
* @ORM\Column(nullable=true)
*/
#[ORM\Column(nullable: true)]
private ?bool $success = null;

Expand Down
3 changes: 3 additions & 0 deletions src/Entity/Log/HistorizableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ trait HistorizableTrait
{
private ?PropertyAccessorInterface $propertyAccess = null;

/**
* @ORM\Column(nullable=true)
*/
#[ORM\Column(nullable: true)]
protected ?array $history = null;

Expand Down
23 changes: 23 additions & 0 deletions src/Entity/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,62 @@

/**
* @author Mathieu Ducrot <[email protected]>
*
* @ORM\Table(name="smart_parameter")
* @ORM\Entity(repositoryClass="Smart\SonataBundle\Repository\ParameterRepository")
*/
#[ORM\Table(name: "smart_parameter")]
#[ORM\Entity(repositoryClass: "Smart\SonataBundle\Repository\ParameterRepository")]
class Parameter implements ParameterInterface
{
use HistorizableTrait;

/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;

/**
* @ORM\Column(name="code", unique=true, nullable=false)
*/
#[ORM\Column(name: "code", unique: true, nullable: false)]
private string $code;

/**
* @ORM\Column(name="value", type="text", nullable=false)
*/
#[ORM\Column(name: "value", type: Types::TEXT, nullable: false)]
private string|bool|null $value = null;

/**
* @ORM\Column(name="help", type="text", nullable=true)
*/
#[ORM\Column(name: "help", type: Types::TEXT, nullable: true)]
private ?string $help = null;

/**
* @ORM\Column(length=15, nullable=false, options={"default"="text"})
*/
#[ORM\Column(length: 15, nullable: false, options: ['default' => 'text'])]
private string $type = ParameterTypeEnum::TEXT;

/**
* MDT We don't need to set the start/end delimiter when setting the regex, it is automatically added when the validate callback is triggered
* @ORM\Column(length=100, nullable=true)
* @Assert\Length(max=100)
*/
#[ORM\Column(length: 100, nullable: true)]
#[Assert\Length(max: 100)]
private ?string $regex = null;

/**
* @param mixed $payload
* @Assert\Callback
*/
#[Assert\Callback]
public function validate(ExecutionContextInterface $context, $payload): void
Expand Down
3 changes: 3 additions & 0 deletions src/Entity/User/PasswordSafeableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

trait PasswordSafeableTrait
{
/**
* @SmartAssert\IsPasswordSafe
*/
#[SmartAssert\IsPasswordSafe]
private ?string $plainPassword = null;
}
24 changes: 23 additions & 1 deletion src/Entity/User/UserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,50 @@
*/
trait UserTrait
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
protected ?int $id = null;

/**
* @ORM\Column(length=255, unique=true, nullable=false)
* @Assert\NotBlank
* @Assert\Email
*/
#[ORM\Column(length: 255, unique: true, nullable: false)]
#[Assert\NotBlank]
#[Assert\Email]
private ?string $email = null;

/**
* @ORM\Column(name="password", length=100, nullable=false)
*/
#[ORM\Column(name: "password", length: 100, nullable: false)]
private ?string $password = null;

private ?string $plainPassword = null;

/**
* @ORM\Column(length=255, nullable=true)
*/
#[ORM\Column(length: 255, nullable: true)]
protected ?string $firstName = null;

/**
* @ORM\Column(length=255, nullable=true)
*/
#[ORM\Column(length: 255, nullable: true)]
protected ?string $lastName = null;

#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
/**
* @ORM\Column(type=Types::DATETIME_MUTABLE, nullable=true)
*/
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
protected ?DateTime $lastLogin = null;

public function __toString()
Expand Down

0 comments on commit 43dc5f4

Please sign in to comment.