src/Flexy/FrontBundle/Entity/MenuItem.php line 20
<?php
namespace App\Flexy\FrontBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Flexy\FrontBundle\Repository\MenuItemRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;
use App\Entity\Link;
use App\Entity\LinkType;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
#[ApiResource]
#[ORM\Entity(repositoryClass: MenuItemRepository::class)]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
#[ORM\Cache(usage:"NONSTRICT_READ_WRITE",region:"append_depend")]
class MenuItem implements \Stringable,Translatable
{
use SoftDeleteableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
#[Gedmo\Translatable]
private ?string $title = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $cssClasses;
#[ORM\Column(type: 'string', length: 255)]
private string $type = "url";
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $routeName = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $routeParam = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $routeParamValue = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $url = null;
#[ORM\ManyToOne(targetEntity: Menu::class, inversedBy: 'menuItems')]
#[ORM\JoinColumn(nullable: false)]
private ?\App\Flexy\FrontBundle\Entity\Menu $menu = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $role = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $anchor;
#[ORM\ManyToOne(targetEntity: MenuItem::class, inversedBy: 'subMenuItems', cascade: ['persist', 'remove'])]
private ?\App\Flexy\FrontBundle\Entity\MenuItem $parentMenuItem = null;
#[ORM\OneToMany(targetEntity: MenuItem::class, mappedBy: 'parentMenuItem', cascade: ['persist', 'remove'])]
private \Doctrine\Common\Collections\Collection|array $subMenuItems;
/**
* @Gedmo\SortablePosition
*/
#[ORM\Column(type: 'integer', nullable: true)]
private $position;
#[ORM\ManyToOne(targetEntity: Link::class, cascade: ['persist'])]
#[ORM\JoinColumn(nullable: true, onDelete: 'CASCADE')]
private $link=null;
#[ORM\ManyToOne(targetEntity: LinkType::class, cascade: ['persist'])]
#[ORM\JoinColumn(nullable: true, onDelete: 'CASCADE')]
private $linkType=null;
#[ORM\Column(type: 'json', nullable: true)]
private $attributes = [];
#[ORM\Column(length: 255,type: 'string', nullable: true)]
private ?string $linkCssClasses = null;
#[ORM\Column(length: 255,type: 'string', nullable: true)]
private ?string $hideIfRole;
/**
* Used locale to override Translation listener`s locale
* this is not a mapped field of entity metadata, just a simple property
*/
#[Gedmo\Locale]
private $locale;
public function __construct()
{
$this->subMenuItems = new ArrayCollection();
}
public function __toString(): string
{
return (string) $this->getTitle();
}
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 getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getRouteName(): ?string
{
return $this->routeName;
}
public function setRouteName(?string $routeName): self
{
$this->routeName = $routeName;
return $this;
}
public function getRouteParam(): ?string
{
return $this->routeParam;
}
public function setRouteParam(?string $routeParam): self
{
$this->routeParam = $routeParam;
return $this;
}
public function getRouteParamValue(): ?string
{
return $this->routeParamValue;
}
public function setRouteParamValue(?string $routeParamValue): self
{
$this->routeParamValue = $routeParamValue;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function getMenu(): ?Menu
{
return $this->menu;
}
public function setMenu(?Menu $menu): self
{
$this->menu = $menu;
return $this;
}
public function getRole(): ?string
{
return $this->role;
}
public function setRole(?string $role): self
{
$this->role = $role;
return $this;
}
public function getParentMenuItem(): ?self
{
return $this->parentMenuItem;
}
public function setParentMenuItem(?self $parentMenuItem): self
{
$this->parentMenuItem = $parentMenuItem;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getSubMenuItems(): Collection
{
return $this->subMenuItems;
}
public function addSubMenuItem(self $subMenuItem): self
{
if (!$this->subMenuItems->contains($subMenuItem)) {
$this->subMenuItems[] = $subMenuItem;
$subMenuItem->setParentMenuItem($this);
}
return $this;
}
public function removeSubMenuItem(self $subMenuItem): self
{
if ($this->subMenuItems->removeElement($subMenuItem)) {
// set the owning side to null (unless already changed)
if ($subMenuItem->getParentMenuItem() === $this) {
$subMenuItem->setParentMenuItem(null);
}
}
return $this;
}
/**
* Get the value of anchor
*/
public function getAnchor()
{
return $this->anchor;
}
/**
* Set the value of anchor
*
* @return self
*/
public function setAnchor($anchor)
{
$this->anchor = $anchor;
return $this;
}
/**
* Get the value of cssClasses
*/
public function getCssClasses()
{
return $this->cssClasses;
}
/**
* Set the value of cssClasses
*
* @return self
*/
public function setCssClasses($cssClasses)
{
$this->cssClasses = $cssClasses;
return $this;
}
/**
* Get the value of link
*/
public function getLink()
{
return $this->link;
}
/**
* Set the value of link
*
* @return self
*/
public function setLink($link)
{
$this->link = $link;
return $this;
}
/**
* Get the value of position
*/
public function getPosition()
{
return $this->position;
}
/**
* Set the value of position
*
* @return self
*/
public function setPosition($position)
{
$this->position = $position;
return $this;
}
/**
* Get the value of linkType
*/
public function getLinkType()
{
return $this->linkType;
}
/**
* Set the value of linkType
*
* @return self
*/
public function setLinkType($linkType)
{
$this->linkType = $linkType;
return $this;
}
/**
* Get the value of attributes
*/
public function getAttributes()
{
return (array)$this->attributes;
}
/**
* Set the value of attributes
*
* @return self
*/
public function setAttributes($attributes)
{
$this->attributes = $attributes;
return $this;
}
public function getLinkCssClasses(): ?string
{
return $this->linkCssClasses;
}
public function setLinkCssClasses(?string $linkCssClasses): self
{
$this->linkCssClasses = $linkCssClasses;
return $this;
}
public function getHideIfRole(): ?string
{
return $this->hideIfRole;
}
public function setHideIfRole(?string $hideIfRole): self
{
$this->hideIfRole = $hideIfRole;
return $this;
}
public function setTranslatableLocale($locale)
{
$this->locale = $locale;
}
}