src/Entity/PhotoUploadErrorReport.php line 40

  1. <?php
  2. /*
  3.  * This file is part of the Pellipop project.
  4.  *
  5.  * (c) Mobizel
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace App\Entity;
  12. use App\Entity\IdentifiableTrait;
  13. use App\Entity\Order\Order;
  14. use App\Entity\Order\OrderItemPhoto;
  15. use App\Repository\PhotoUploadErrorReportRepository;
  16. use Doctrine\DBAL\Types\Types;
  17. use Doctrine\ORM\Mapping as ORM;
  18. use Gedmo\Timestampable\Traits\TimestampableEntity;
  19. use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
  20. use Sylius\Component\Resource\Model\ResourceInterface;
  21. #[ORM\Entity(repositoryClassPhotoUploadErrorReportRepository::class)]
  22. #[ORM\Table(name'app_photo_upload_error_report')]
  23. #[SyliusCrudRoutes(alias'app.photo_upload_error_report'path'/admin/photo-upload-errors'section'backend'templates'backend/photo_upload_error_report'grid'app_backend_photo_upload_error_report'only: ['index''show'], vars: [
  24.     'all' => [
  25.         'subheader' => 'app.ui.photo_upload_errors',
  26.     ],
  27.     'index' => [
  28.         'icon' => 'exclamation triangle',
  29.     ],
  30. ])]
  31. #[ORM\Index(columns: ['order_id'], name'idx_order_id')]
  32. #[ORM\Index(columns: ['photo_id'], name'idx_photo_id')]
  33. #[ORM\Index(columns: ['error_type'], name'idx_error_type')]
  34. #[ORM\Index(columns: ['resolved'], name'idx_resolved')]
  35. class PhotoUploadErrorReport implements ResourceInterface
  36. {
  37.     use IdentifiableTrait;
  38.     use TimestampableEntity;
  39.     public const ERROR_TYPE_FILE_MISSING 'file_missing';
  40.     public const ERROR_TYPE_FILE_CORRUPTED 'file_corrupted';
  41.     public const ERROR_TYPE_STATE_TRANSITION 'state_transition';
  42.     public const ERROR_TYPE_FUJI_SERVER 'fuji_server';
  43.     public const ERROR_TYPE_NETWORK 'network';
  44.     public const ERROR_TYPE_COMPRESSION 'compression';
  45.     public const ERROR_TYPE_UNKNOWN 'unknown';
  46.     public const SOURCE_API 'api';
  47.     public const SOURCE_COMMAND 'command';
  48.     public const SOURCE_APP 'app';
  49.     #[ORM\ManyToOne(targetEntityOrder::class)]
  50.     #[ORM\JoinColumn(name'order_id'referencedColumnName'id'nullabletrueonDelete'CASCADE')]
  51.     private ?Order $order null;
  52.     #[ORM\ManyToOne(targetEntityOrderItemPhoto::class)]
  53.     #[ORM\JoinColumn(name'photo_id'referencedColumnName'id'nullabletrueonDelete'SET NULL')]
  54.     private ?OrderItemPhoto $photo null;
  55.     #[ORM\Column(length50)]
  56.     private string $errorType;
  57.     #[ORM\Column(length20)]
  58.     private string $source;
  59.     #[ORM\Column(typeTypes::TEXT)]
  60.     private string $errorMessage;
  61.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  62.     private ?string $stackTrace null;
  63.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  64.     private ?array $context null;
  65.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  66.     private bool $resolved false;
  67.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  68.     private ?string $resolutionNote null;
  69.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLEnullabletrue)]
  70.     private ?\DateTimeImmutable $resolvedAt null;
  71.     public function getId(): ?int
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function getOrder(): ?Order
  76.     {
  77.         return $this->order;
  78.     }
  79.     public function setOrder(?Order $order): self
  80.     {
  81.         $this->order $order;
  82.         return $this;
  83.     }
  84.     public function getPhoto(): ?OrderItemPhoto
  85.     {
  86.         return $this->photo;
  87.     }
  88.     public function setPhoto(?OrderItemPhoto $photo): self
  89.     {
  90.         $this->photo $photo;
  91.         return $this;
  92.     }
  93.     public function getErrorType(): string
  94.     {
  95.         return $this->errorType;
  96.     }
  97.     public function setErrorType(string $errorType): self
  98.     {
  99.         $this->errorType $errorType;
  100.         return $this;
  101.     }
  102.     public function getSource(): string
  103.     {
  104.         return $this->source;
  105.     }
  106.     public function setSource(string $source): self
  107.     {
  108.         $this->source $source;
  109.         return $this;
  110.     }
  111.     public function getErrorMessage(): string
  112.     {
  113.         return $this->errorMessage;
  114.     }
  115.     public function setErrorMessage(string $errorMessage): self
  116.     {
  117.         $this->errorMessage $errorMessage;
  118.         return $this;
  119.     }
  120.     public function getStackTrace(): ?string
  121.     {
  122.         return $this->stackTrace;
  123.     }
  124.     public function setStackTrace(?string $stackTrace): self
  125.     {
  126.         $this->stackTrace $stackTrace;
  127.         return $this;
  128.     }
  129.     public function getContext(): ?array
  130.     {
  131.         return $this->context;
  132.     }
  133.     public function setContext(?array $context): self
  134.     {
  135.         $this->context $context;
  136.         return $this;
  137.     }
  138.     public function isResolved(): bool
  139.     {
  140.         return $this->resolved;
  141.     }
  142.     public function setResolved(bool $resolved): self
  143.     {
  144.         $this->resolved $resolved;
  145.         if ($resolved && $this->resolvedAt === null) {
  146.             $this->resolvedAt = new \DateTimeImmutable();
  147.         } elseif (!$resolved) {
  148.             $this->resolvedAt null;
  149.         }
  150.         return $this;
  151.     }
  152.     public function getResolutionNote(): ?string
  153.     {
  154.         return $this->resolutionNote;
  155.     }
  156.     public function setResolutionNote(?string $resolutionNote): self
  157.     {
  158.         $this->resolutionNote $resolutionNote;
  159.         return $this;
  160.     }
  161.     public function getResolvedAt(): ?\DateTimeImmutable
  162.     {
  163.         return $this->resolvedAt;
  164.     }
  165.     public function setResolvedAt(?\DateTimeImmutable $resolvedAt): self
  166.     {
  167.         $this->resolvedAt $resolvedAt;
  168.         return $this;
  169.     }
  170.     public static function getErrorTypeChoices(): array
  171.     {
  172.         return [
  173.             self::ERROR_TYPE_FILE_MISSING => 'Fichier manquant',
  174.             self::ERROR_TYPE_FILE_CORRUPTED => 'Fichier corrompu',
  175.             self::ERROR_TYPE_STATE_TRANSITION => 'Transition d\'état impossible',
  176.             self::ERROR_TYPE_FUJI_SERVER => 'Erreur serveur Fuji',
  177.             self::ERROR_TYPE_NETWORK => 'Erreur réseau',
  178.             self::ERROR_TYPE_UNKNOWN => 'Erreur inconnue',
  179.         ];
  180.     }
  181.     public static function getSourceChoices(): array
  182.     {
  183.         return [
  184.             self::SOURCE_API => 'API',
  185.             self::SOURCE_COMMAND => 'Commande',
  186.             self::SOURCE_APP => 'Application mobile',
  187.         ];
  188.     }
  189. }