112 lines
2.5 KiB
PHP
112 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace MyDevel\Webroot\Entity;
|
|
|
|
use App\Repository\WebrootFileRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: WebrootFileRepository::class,)]
|
|
#[ORM\Table(name:'mydevel_webroot_file')]
|
|
class WebrootFile
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 65535,nullable:false)]
|
|
private ?string $url = null;
|
|
|
|
#[ORM\Column(length: 65535,nullable:false)]
|
|
private ?string $abspath = null;
|
|
|
|
|
|
/**
|
|
* @var Collection<int, WebrootPermission>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: WebrootFilePermission::class, mappedBy: 'webrootFile', orphanRemoval: true)]
|
|
private Collection $permissions;
|
|
|
|
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?WebrootUser $owner = null;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->permissions = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getUrl(): ?string
|
|
{
|
|
return $this->url;
|
|
}
|
|
|
|
public function setUrl(string $url): static
|
|
{
|
|
$this->url = $url;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAbspath(): ?string
|
|
{
|
|
return $this->abspath;
|
|
}
|
|
|
|
public function setAbspath(string $abspath): static
|
|
{
|
|
$this->abspath = $abspath;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, WebrootPermission>
|
|
*/
|
|
public function getPermissions(): Collection
|
|
{
|
|
return $this->permissions;
|
|
}
|
|
|
|
public function addPermission(WebrootPermission $permission): static
|
|
{
|
|
if (!$this->permissions->contains($permission)) {
|
|
$this->permissions->add($permission);
|
|
$permission->setWebrootFile($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removePermission(WebrootFilePermission $permission): static
|
|
{
|
|
if ($this->permissions->removeElement($permission)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($permission->getWebrootFile() === $this) {
|
|
$permission->setWebrootFile(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getOwner(): ?WebrootUser
|
|
{
|
|
return $this->owner;
|
|
}
|
|
|
|
public function setOwner(WebrootUser $owner): static
|
|
{
|
|
$this->owner = $owner;
|
|
|
|
return $this;
|
|
}
|
|
}
|