src/Cms/SyncBundle/Entity/Sync.php line 26

Open in your IDE?
  1. <?php
  2. namespace Cms\SyncBundle\Entity;
  3. use App\Model\Async\StringSemaphoreInterface;
  4. use App\Model\Async\StringSemaphoreTrait;
  5. use Cms\ContainerBundle\Entity\Container;
  6. use Cms\ImportBundle\Model\Interfaces\Importable\ImportableInterface;
  7. use Cms\ImportBundle\Model\Interfaces\Importable\ImportableTrait;
  8. use Cms\TenantBundle\Entity\TenantedEntity;
  9. use DateTimeInterface;
  10. use Doctrine\ORM\Mapping as ORM;
  11. /**
  12.  * Class Sync
  13.  * @package Cms\SyncBundle\Entity
  14.  *
  15.  * @ORM\Entity(
  16.  *     repositoryClass = "Cms\SyncBundle\Doctrine\SyncRepository"
  17.  * )
  18.  * @ORM\HasLifecycleCallbacks
  19.  * @ORM\Table(
  20.  *     name = "cms__sync__sync"
  21.  * )
  22.  */
  23. class Sync extends TenantedEntity implements ImportableInterfaceStringSemaphoreInterface
  24. {
  25.     use ImportableTrait;
  26.     use StringSemaphoreTrait;
  27.     public const STATUS__STARTED 'started';
  28.     public const STATUS__STOPPED 'stopped';
  29.     /**
  30.      * @var string|null
  31.      *
  32.      * @ORM\Column(
  33.      *     type = "string",
  34.      *     nullable = false,
  35.      * )
  36.      */
  37.     protected ?string $name null;
  38.     /**
  39.      * @var string|null
  40.      *
  41.      * @ORM\Column(
  42.      *     type = "text",
  43.      *     nullable = true,
  44.      * )
  45.      */
  46.     protected ?string $description null;
  47.     /**
  48.      * @var string|null
  49.      *
  50.      * @ORM\Column(
  51.      *     type = "string",
  52.      *     nullable = false,
  53.      * )
  54.      */
  55.     protected ?string $type null;
  56.     /**
  57.      * @var string
  58.      *
  59.      * @ORM\Column(
  60.      *     type = "string",
  61.      *     nullable = false,
  62.      *     options = {
  63.      *          "default" = self::STATUS__STOPPED,
  64.      *     },
  65.      * )
  66.      */
  67.     protected string $status self::STATUS__STOPPED;
  68.     /**
  69.      * @var string|null
  70.      *
  71.      * @ORM\Column(
  72.      *     type = "text",
  73.      *     nullable = true,
  74.      * )
  75.      */
  76.     protected ?string $errors null;
  77.     /**
  78.      * @var string|null
  79.      *
  80.      * @ORM\Column(
  81.      *     type = "string",
  82.      *     nullable = false,
  83.      * )
  84.      */
  85.     protected ?string $url null;
  86.     /**
  87.      * @var int
  88.      *
  89.      * @ORM\Column(
  90.      *     type = "integer",
  91.      *     nullable = true,
  92.      *     options = {
  93.      *         "unsigned" = true,
  94.      *     },
  95.      * )
  96.      */
  97.     protected int $frequency 0;
  98.     /**
  99.      * @var Container|null
  100.      *
  101.      * @ORM\ManyToOne(
  102.      *     targetEntity = Container::class,
  103.      * )
  104.      * @ORM\JoinColumn(
  105.      *     name = "container",
  106.      *     referencedColumnName = "id",
  107.      *     onDelete = "CASCADE",
  108.      * )
  109.      */
  110.     protected ?Container $container null;
  111.     /**
  112.      * @var string|null
  113.      *
  114.      * @ORM\Column(
  115.      *     type = "string",
  116.      *     nullable = true,
  117.      * )
  118.      */
  119.     protected ?string $checksum null;
  120.     /**
  121.      * @var DateTimeInterface|null
  122.      *
  123.      * @ORM\Column(
  124.      *     type = "datetime",
  125.      *     nullable = true,
  126.      * )
  127.      */
  128.     protected ?DateTimeInterface $lastSyncAt null;
  129.     /**
  130.      * @var DateTimeInterface|null
  131.      *
  132.      * @ORM\Column(
  133.      *     type = "datetime",
  134.      *     nullable = true,
  135.      * )
  136.      */
  137.     protected ?DateTimeInterface $nextSyncAt null;
  138.     /**
  139.      * @var DateTimeInterface|null
  140.      *
  141.      * @ORM\Column(
  142.      *     type = "datetime",
  143.      *     nullable = true,
  144.      * )
  145.      */
  146.     protected ?DateTimeInterface $lastErrorAt null;
  147.     /**
  148.      * @var int
  149.      *
  150.      * @ORM\Column(
  151.      *     type = "integer",
  152.      *     nullable = false,
  153.      *     options = {
  154.      *         "unsigned" = true,
  155.      *         "default" = 0,
  156.      *     },
  157.      * )
  158.      */
  159.     protected int $errorCount 0;
  160.     /**
  161.      * @return string|null
  162.      */
  163.     public function getChecksum(): ?string
  164.     {
  165.         return $this->checksum;
  166.     }
  167.     /**
  168.      * @param string|null $checksum
  169.      * @return $this
  170.      */
  171.     public function setChecksum(?string $checksum): self
  172.     {
  173.         $this->checksum $checksum ?: null;
  174.         return $this;
  175.     }
  176.     /**
  177.      * @return string|null
  178.      */
  179.     public function getName(): ?string
  180.     {
  181.         return $this->name;
  182.     }
  183.     /**
  184.      * @param string|null $name
  185.      * @return $this
  186.      */
  187.     public function setName(?string $name): self
  188.     {
  189.         $this->name $name ?: null;
  190.         return $this;
  191.     }
  192.     /**
  193.      * @return string|null
  194.      */
  195.     public function getDescription(): ?string
  196.     {
  197.         return $this->description;
  198.     }
  199.     /**
  200.      * @param string|null $description
  201.      * @return $this
  202.      */
  203.     public function setDescription(?string $description): self
  204.     {
  205.         $this->description $description ?: null;
  206.         return $this;
  207.     }
  208.     /**
  209.      * @return string|null
  210.      */
  211.     public function getType(): ?string
  212.     {
  213.         return $this->type;
  214.     }
  215.     /**
  216.      * @param string|null $type
  217.      * @return $this
  218.      */
  219.     public function setType(?string $type): self
  220.     {
  221.         $this->type $type ?: null;
  222.         return $this;
  223.     }
  224.     /**
  225.      * @return string|null
  226.      */
  227.     public function getErrors(): ?string
  228.     {
  229.         return $this->errors;
  230.     }
  231.     /**
  232.      * @param string|null $errors
  233.      * @return $this
  234.      */
  235.     public function setErrors(?string $errors): self
  236.     {
  237.         $this->errors $errors ?: null;
  238.         return $this;
  239.     }
  240.     /**
  241.      * @return string|null
  242.      */
  243.     public function getUrl(): ?string
  244.     {
  245.         return $this->url;
  246.     }
  247.     /**
  248.      * @param string|null $url
  249.      * @return $this
  250.      */
  251.     public function setUrl(?string $url): self
  252.     {
  253.         $this->url $url ?: null;
  254.         return $this;
  255.     }
  256.     /**
  257.      * @return int
  258.      */
  259.     public function getFrequency(): int
  260.     {
  261.         return $this->frequency;
  262.     }
  263.     /**
  264.      * @param int $frequency
  265.      * @return $this
  266.      */
  267.     public function setFrequency(int $frequency): self
  268.     {
  269.         $this->frequency $frequency;
  270.         return $this;
  271.     }
  272.     /**
  273.      * @return Container|null
  274.      */
  275.     public function getContainer(): ?Container
  276.     {
  277.         return $this->container;
  278.     }
  279.     /**
  280.      * @param Container|null $container
  281.      * @return $this
  282.      */
  283.     public function setContainer(?Container $container): self
  284.     {
  285.         $this->container $container;
  286.         return $this;
  287.     }
  288.     /**
  289.      * @return string
  290.      */
  291.     public function getStatus(): string
  292.     {
  293.         return $this->status;
  294.     }
  295.     /**
  296.      * @param string $status
  297.      * @return $this
  298.      */
  299.     public function setStatus(string $status): self
  300.     {
  301.         $this->status $status;
  302.         return $this;
  303.     }
  304.     /**
  305.      * @return DateTimeInterface|null
  306.      */
  307.     public function getLastSyncAt(): ?DateTimeInterface
  308.     {
  309.         return $this->lastSyncAt;
  310.     }
  311.     /**
  312.      * @param DateTimeInterface|null $lastSyncAt
  313.      * @return $this
  314.      */
  315.     public function setLastSyncAt(?DateTimeInterface $lastSyncAt): self
  316.     {
  317.         $this->lastSyncAt $lastSyncAt;
  318.         return $this;
  319.     }
  320.     /**
  321.      * @return DateTimeInterface|null
  322.      */
  323.     public function getNextSyncAt(): ?DateTimeInterface
  324.     {
  325.         return $this->nextSyncAt;
  326.     }
  327.     /**
  328.      * @param DateTimeInterface|null $nextSyncAt
  329.      * @return $this
  330.      */
  331.     public function setNextSyncAt(?DateTimeInterface $nextSyncAt): self
  332.     {
  333.         $this->nextSyncAt $nextSyncAt;
  334.         return $this;
  335.     }
  336.     /**
  337.      * @return bool
  338.      */
  339.     public function isStarted(): bool
  340.     {
  341.         return $this->getStatus() === self::STATUS__STARTED;
  342.     }
  343.     /**
  344.      * @return DateTimeInterface|null
  345.      */
  346.     public function getLastErrorAt(): ?DateTimeInterface
  347.     {
  348.         return $this->lastErrorAt;
  349.     }
  350.     /**
  351.      * @param DateTimeInterface|null $lastErrorAt
  352.      * @return $this
  353.      */
  354.     public function setLastErrorAt(?DateTimeInterface $lastErrorAt): self
  355.     {
  356.         $this->lastErrorAt $lastErrorAt;
  357.         return $this;
  358.     }
  359.     /**
  360.      * @return int
  361.      */
  362.     public function getErrorCount(): int
  363.     {
  364.         return $this->errorCount;
  365.     }
  366.     /**
  367.      * @param int $errorCount
  368.      * @return $this
  369.      */
  370.     public function setErrorCount(int $errorCount): self
  371.     {
  372.         $this->errorCount $errorCount;
  373.         return $this;
  374.     }
  375. }