Skip to content

Commit

Permalink
Migrate to PHP attributes #9606
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi committed Apr 25, 2023
1 parent 0dcf099 commit 9d1be2e
Show file tree
Hide file tree
Showing 17 changed files with 120 additions and 206 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"cakephp/chronos": "^2.3",
"doctrine/dbal": "^3.5",
"doctrine/migrations": "^3.5",
"ecodev/graphql-doctrine": "^7.3",
"ecodev/graphql-doctrine": "^8.0",
"imagine/imagine": "^1.3",
"laminas/laminas-diactoros": "^2.21",
"laminas/laminas-log": "^2.15",
Expand Down
87 changes: 44 additions & 43 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Model/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Ecodev\Felix\Model;

use Cake\Chronos\Chronos;
use GraphQL\Doctrine\Attribute as API;

interface Message extends Model
{
Expand All @@ -20,9 +21,8 @@ public function getDateSent(): ?Chronos;

/**
* Set sent time.
*
* @API\Exclude
*/
#[Api\Exclude]
public function setDateSent(?Chronos $dateSent): void;

/**
Expand Down
24 changes: 8 additions & 16 deletions src/Model/Traits/AbstractFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Doctrine\ORM\Mapping as ORM;
use Exception;
use GraphQL\Doctrine\Annotation as API;
use GraphQL\Doctrine\Attribute as API;
use Psr\Http\Message\UploadedFileInterface;

/**
Expand All @@ -26,15 +26,11 @@ abstract protected function getBasePath(): string;
*/
abstract protected function getAcceptedMimeTypes(): array;

/**
* @API\Exclude
* @ORM\Column(type="string", length=190, options={"default" = ""})
*/
#[ORM\Column(type: 'string', length: 190, options: ['default' => ''])]
#[API\Exclude]
private string $filename = '';

/**
* @ORM\Column(type="string", length=255, options={"default" = ""})
*/
#[ORM\Column(type: 'string', length: 255, options: ['default' => ''])]
private string $mime = '';

/**
Expand All @@ -55,19 +51,17 @@ public function setFile(UploadedFileInterface $file): void

/**
* Set filename (without path).
*
* @API\Exclude
*/
#[API\Exclude]
public function setFilename(string $filename): void
{
$this->filename = $filename;
}

/**
* Get filename (without path).
*
* @API\Exclude
*/
#[API\Exclude]
public function getFilename(): string
{
return $this->filename;
Expand All @@ -83,9 +77,8 @@ public function getMime(): string

/**
* Get absolute path to file on disk.
*
* @API\Exclude
*/
#[API\Exclude]
public function getPath(): string
{
return realpath('.') . '/' . $this->getBasePath() . $this->getFilename();
Expand All @@ -95,9 +88,8 @@ public function getPath(): string
* Automatically called by Doctrine when the object is deleted
* Is called after database update because we can have issues on remove operation (like integrity test)
* and it's preferable to keep a related file on drive before removing it definitely.
*
* @ORM\PostRemove
*/
#[ORM\PostRemove]
public function deleteFile(): void
{
$path = $this->getPath();
Expand Down
4 changes: 1 addition & 3 deletions src/Model/Traits/HasDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

trait HasDescription
{
/**
* @ORM\Column(type="text", length=65535)
*/
#[ORM\Column(type: 'text', length: 65535)]
private string $description = '';

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Model/Traits/HasInternalRemarks.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

trait HasInternalRemarks
{
/**
* @ORM\Column(type="text", length=65535)
*/
#[ORM\Column(type: 'text', length: 65535)]
private string $internalRemarks = '';

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Model/Traits/HasName.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
*/
trait HasName
{
/**
* @ORM\Column(type="string", length=191)
*/
#[ORM\Column(type: 'string', length: 191)]
private string $name = '';

/**
Expand Down
Loading

0 comments on commit 9d1be2e

Please sign in to comment.