360 lines
6.9 KiB
PHP
Executable File
360 lines
6.9 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="item")
|
|
* @ORM\Entity(repositoryClass="App\Repository\ItemRepository")
|
|
*/
|
|
class Item
|
|
{
|
|
/**
|
|
* @var int
|
|
*
|
|
* @ORM\Column(name="id", type="integer")
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="title", type="string", length=100)
|
|
*/
|
|
private $title;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="subtitle", type="string", length=250, nullable=true)
|
|
*/
|
|
private $subtitle;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(length=128, unique=true, nullable=true)
|
|
*/
|
|
private $slug;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="url", type="string", length=500)
|
|
*/
|
|
private $url;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="target", type="string", length=32)
|
|
*/
|
|
private $target;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="content", type="text", nullable=true)
|
|
*/
|
|
private $content;
|
|
|
|
/**
|
|
* @var int
|
|
*
|
|
* @ORM\Column(name="rowOrder", type="integer", nullable=true)
|
|
*/
|
|
private $rowOrder;
|
|
|
|
/**
|
|
* @var bool
|
|
*
|
|
* @ORM\Column(name="essential", type="boolean", nullable=true, options={"default":false})
|
|
*/
|
|
private $essential = false;
|
|
|
|
/**
|
|
* @var bool
|
|
*
|
|
* @ORM\Column(name="protected", type="boolean", nullable=true, options={"default":false})
|
|
*/
|
|
private $protected;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="color", type="string", length=24, nullable=true)
|
|
*/
|
|
private $color;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="roles", type="array", nullable=true)
|
|
*/
|
|
private $roles;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="Icon", inversedBy="items")
|
|
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
|
|
*/
|
|
private $icon;
|
|
|
|
/**
|
|
* @var ArrayCollection
|
|
* @var Bookmark
|
|
*
|
|
* @ORM\OneToMany(targetEntity="Bookmark", mappedBy="item", cascade={"persist"}, orphanRemoval=true)
|
|
*/
|
|
private $bookmarks;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="Itemcategory", inversedBy="items")
|
|
* @ORM\JoinColumn(name="category", referencedColumnName="id", nullable=false, onDelete="CASCADE")
|
|
*/
|
|
protected $itemcategory;
|
|
|
|
/**
|
|
* @ORM\ManyToMany(targetEntity="Group", inversedBy="items", cascade={"persist"})
|
|
* @ORM\JoinTable(name="itemgroupe",
|
|
* joinColumns={@ORM\JoinColumn(name="item", referencedColumnName="id")},
|
|
* inverseJoinColumns={@ORM\JoinColumn(name="groupe", referencedColumnName="id")}
|
|
* )
|
|
*/
|
|
protected $groups;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->bookmarks = new ArrayCollection();
|
|
$this->groups = new ArrayCollection();
|
|
}
|
|
|
|
// A garder pour forcer l'id en init
|
|
public function setId($id)
|
|
{
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getTitle(): ?string
|
|
{
|
|
return $this->title;
|
|
}
|
|
|
|
public function setTitle(string $title): self
|
|
{
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getSubtitle(): ?string
|
|
{
|
|
return $this->subtitle;
|
|
}
|
|
|
|
public function setSubtitle(?string $subtitle): self
|
|
{
|
|
$this->subtitle = $subtitle;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getSlug(): ?string
|
|
{
|
|
return $this->slug;
|
|
}
|
|
|
|
public function setSlug(?string $slug): self
|
|
{
|
|
$this->slug = $slug;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getUrl(): ?string
|
|
{
|
|
return $this->url;
|
|
}
|
|
|
|
public function setUrl(string $url): self
|
|
{
|
|
$this->url = $url;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTarget(): ?string
|
|
{
|
|
return $this->target;
|
|
}
|
|
|
|
public function setTarget(string $target): self
|
|
{
|
|
$this->target = $target;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getContent(): ?string
|
|
{
|
|
return $this->content;
|
|
}
|
|
|
|
public function setContent(?string $content): self
|
|
{
|
|
$this->content = $content;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getRowOrder(): ?int
|
|
{
|
|
return $this->rowOrder;
|
|
}
|
|
|
|
public function setRowOrder(?int $rowOrder): self
|
|
{
|
|
$this->rowOrder = $rowOrder;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isEssential(): ?bool
|
|
{
|
|
return $this->essential;
|
|
}
|
|
|
|
public function setEssential(?bool $essential): self
|
|
{
|
|
$this->essential = $essential;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isProtected(): ?bool
|
|
{
|
|
return $this->protected;
|
|
}
|
|
|
|
public function setProtected(?bool $protected): self
|
|
{
|
|
$this->protected = $protected;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getColor(): ?string
|
|
{
|
|
return $this->color;
|
|
}
|
|
|
|
public function setColor(?string $color): self
|
|
{
|
|
$this->color = $color;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getRoles(): array
|
|
{
|
|
return $this->roles;
|
|
}
|
|
|
|
public function setRoles(?array $roles): self
|
|
{
|
|
$this->roles = $roles;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getIcon(): ?Icon
|
|
{
|
|
return $this->icon;
|
|
}
|
|
|
|
public function setIcon(?Icon $icon): self
|
|
{
|
|
$this->icon = $icon;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Bookmark>
|
|
*/
|
|
public function getBookmarks(): Collection
|
|
{
|
|
return $this->bookmarks;
|
|
}
|
|
|
|
public function addBookmark(Bookmark $bookmark): self
|
|
{
|
|
if (!$this->bookmarks->contains($bookmark)) {
|
|
$this->bookmarks->add($bookmark);
|
|
$bookmark->setItem($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeBookmark(Bookmark $bookmark): self
|
|
{
|
|
if ($this->bookmarks->removeElement($bookmark)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($bookmark->getItem() === $this) {
|
|
$bookmark->setItem(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getItemcategory(): ?Itemcategory
|
|
{
|
|
return $this->itemcategory;
|
|
}
|
|
|
|
public function setItemcategory(?Itemcategory $itemcategory): self
|
|
{
|
|
$this->itemcategory = $itemcategory;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Group>
|
|
*/
|
|
public function getGroups(): Collection
|
|
{
|
|
return $this->groups;
|
|
}
|
|
|
|
public function addGroup(Group $group): self
|
|
{
|
|
if (!$this->groups->contains($group)) {
|
|
$this->groups->add($group);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeGroup(Group $group): self
|
|
{
|
|
$this->groups->removeElement($group);
|
|
|
|
return $this;
|
|
}
|
|
}
|