<?php
namespace Sq\Entity\Schema\ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Sq\Entity\Schema\Column\ImportFolderContext;
use Sq\Entity\Schema\Column\ImportFolderType;
/**
* ImportFolder.
*/
#[ORM\Entity]
#[ORM\Table(name: 'import_folder')]
#[ORM\Index(name: 'if_folder_order', columns: ['if_type', 'if_m_id', 'if_order'])]
#[ORM\UniqueConstraint(name: 'folder_name', columns: ['if_m_id', 'if_name'])]
class ImportFolder implements BelongsToWorkspaceInterface
{
/**
* @var int
*/
#[ORM\Column(name: 'if_id', type: 'integer', nullable: false, options: ['unsigned' => true])]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private $id;
/**
* @var string|null
*/
#[ORM\Column(name: 'if_type', type: 'string', length: 0, nullable: true, options: ['default' => 'global'])]
private $type = ImportFolderType::GLOBAL;
/**
* @var Member|null
*/
#[ORM\ManyToOne(targetEntity: Member::class)]
#[ORM\JoinColumn(name: 'if_m_id', referencedColumnName: 'm_id', nullable: true)]
private $member;
/**
* @var string
*/
#[ORM\Column(name: 'if_context', type: 'string', length: 0, nullable: false, options: ['default' => 'import'])]
private $context = ImportFolderContext::IMPORT;
/**
* @var int
*/
#[ORM\Column(name: 'if_order', type: 'smallint', nullable: false, options: ['unsigned' => true])]
private $order;
/**
* @var string|null
*/
#[ORM\Column(name: 'if_name', type: 'string', length: 191, nullable: true)]
private $name;
/**
* @var Workspace|null
*/
#[ORM\ManyToOne(targetEntity: Workspace::class, inversedBy: 'importFolders')]
#[ORM\JoinColumn(name: 'if_ws_id', referencedColumnName: 'ws_id', nullable: true)]
private $workspace;
/**
* @var Collection|ImportSource[]
*/
#[ORM\OneToMany(targetEntity: ImportSource::class, mappedBy: 'importFolder', cascade: ['remove'])]
private $importSources;
public function __construct(string $context, int $order)
{
$this->context = $context;
$this->order = $order;
$this->importSources = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getMember(): ?Member
{
return $this->member;
}
public function setMember(?Member $member): self
{
$this->member = $member;
return $this;
}
public function getContext(): string
{
return $this->context;
}
public function setContext(string $context): self
{
$this->context = $context;
return $this;
}
public function getOrder(): int
{
return $this->order;
}
public function setOrder(int $order): self
{
$this->order = $order;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getWorkspace(): Workspace
{
return $this->workspace;
}
public function setWorkspace(Workspace $workspace): self
{
$this->workspace = $workspace;
return $this;
}
/**
* @return Collection|ImportSource[]
*/
public function getImportSources(): Collection
{
return $this->importSources
->filter(fn (ImportSource $importSource): bool => $importSource->getAutoImport() === null);
}
public function isLegacyWithoutWorkspace(): bool
{
return $this->workspace === null;
}
}