app/Entity/Schema/ORM/ImportFolder.php line 18

Open in your IDE?
  1. <?php
  2. namespace Sq\Entity\Schema\ORM;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Sq\Entity\Schema\Column\ImportFolderContext;
  7. use Sq\Entity\Schema\Column\ImportFolderType;
  8. /**
  9.  * ImportFolder.
  10.  */
  11. #[ORM\Entity]
  12. #[ORM\Table(name'import_folder')]
  13. #[ORM\Index(name'if_folder_order'columns: ['if_type''if_m_id''if_order'])]
  14. #[ORM\UniqueConstraint(name'folder_name'columns: ['if_m_id''if_name'])]
  15. class ImportFolder implements BelongsToWorkspaceInterface
  16. {
  17.     /**
  18.      * @var int
  19.      */
  20.     #[ORM\Column(name'if_id'type'integer'nullablefalseoptions: ['unsigned' => true])]
  21.     #[ORM\Id]
  22.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  23.     private $id;
  24.     /**
  25.      * @var string|null
  26.      */
  27.     #[ORM\Column(name'if_type'type'string'length0nullabletrueoptions: ['default' => 'global'])]
  28.     private $type ImportFolderType::GLOBAL;
  29.     /**
  30.      * @var Member|null
  31.      */
  32.     #[ORM\ManyToOne(targetEntityMember::class)]
  33.     #[ORM\JoinColumn(name'if_m_id'referencedColumnName'm_id'nullabletrue)]
  34.     private $member;
  35.     /**
  36.      * @var string
  37.      */
  38.     #[ORM\Column(name'if_context'type'string'length0nullablefalseoptions: ['default' => 'import'])]
  39.     private $context ImportFolderContext::IMPORT;
  40.     /**
  41.      * @var int
  42.      */
  43.     #[ORM\Column(name'if_order'type'smallint'nullablefalseoptions: ['unsigned' => true])]
  44.     private $order;
  45.     /**
  46.      * @var string|null
  47.      */
  48.     #[ORM\Column(name'if_name'type'string'length191nullabletrue)]
  49.     private $name;
  50.     /**
  51.      * @var Workspace|null
  52.      */
  53.     #[ORM\ManyToOne(targetEntityWorkspace::class, inversedBy'importFolders')]
  54.     #[ORM\JoinColumn(name'if_ws_id'referencedColumnName'ws_id'nullabletrue)]
  55.     private $workspace;
  56.     /**
  57.      * @var Collection|ImportSource[]
  58.      */
  59.     #[ORM\OneToMany(targetEntityImportSource::class, mappedBy'importFolder'cascade: ['remove'])]
  60.     private $importSources;
  61.     public function __construct(string $contextint $order)
  62.     {
  63.         $this->context $context;
  64.         $this->order $order;
  65.         $this->importSources = new ArrayCollection();
  66.     }
  67.     public function getId(): ?int
  68.     {
  69.         return $this->id;
  70.     }
  71.     public function getType(): ?string
  72.     {
  73.         return $this->type;
  74.     }
  75.     public function setType(?string $type): self
  76.     {
  77.         $this->type $type;
  78.         return $this;
  79.     }
  80.     public function getMember(): ?Member
  81.     {
  82.         return $this->member;
  83.     }
  84.     public function setMember(?Member $member): self
  85.     {
  86.         $this->member $member;
  87.         return $this;
  88.     }
  89.     public function getContext(): string
  90.     {
  91.         return $this->context;
  92.     }
  93.     public function setContext(string $context): self
  94.     {
  95.         $this->context $context;
  96.         return $this;
  97.     }
  98.     public function getOrder(): int
  99.     {
  100.         return $this->order;
  101.     }
  102.     public function setOrder(int $order): self
  103.     {
  104.         $this->order $order;
  105.         return $this;
  106.     }
  107.     public function getName(): ?string
  108.     {
  109.         return $this->name;
  110.     }
  111.     public function setName(?string $name): self
  112.     {
  113.         $this->name $name;
  114.         return $this;
  115.     }
  116.     public function getWorkspace(): Workspace
  117.     {
  118.         return $this->workspace;
  119.     }
  120.     public function setWorkspace(Workspace $workspace): self
  121.     {
  122.         $this->workspace $workspace;
  123.         return $this;
  124.     }
  125.     /**
  126.      * @return Collection|ImportSource[]
  127.      */
  128.     public function getImportSources(): Collection
  129.     {
  130.         return $this->importSources
  131.             ->filter(fn (ImportSource $importSource): bool => $importSource->getAutoImport() === null);
  132.     }
  133.     public function isLegacyWithoutWorkspace(): bool
  134.     {
  135.         return $this->workspace === null;
  136.     }
  137. }