2020-04-11 17:34:01 +02:00
|
|
|
<?php
|
2022-11-29 21:21:26 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published
|
|
|
|
* by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-05-10 21:39:31 +02:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-04-11 17:34:01 +02:00
|
|
|
/**
|
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
|
|
|
*
|
2022-11-29 22:28:53 +01:00
|
|
|
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
|
2020-04-11 17:34:01 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published
|
|
|
|
* by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Entity\LabelSystem;
|
|
|
|
|
|
|
|
use App\Entity\Attachments\AttachmentContainingDBElement;
|
|
|
|
use App\Entity\Attachments\LabelAttachment;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
|
2023-05-28 01:21:05 +02:00
|
|
|
#[UniqueEntity(['name', 'options.supported_element'])]
|
2023-06-11 14:15:46 +02:00
|
|
|
#[ORM\Entity(repositoryClass: \App\Repository\LabelProfileRepository::class)]
|
|
|
|
#[ORM\EntityListeners([\App\EntityListeners\TreeCacheInvalidationListener::class])]
|
2023-05-28 01:33:45 +02:00
|
|
|
#[ORM\Table(name: 'label_profiles')]
|
2020-04-11 17:34:01 +02:00
|
|
|
class LabelProfile extends AttachmentContainingDBElement
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var Collection<int, LabelAttachment>
|
|
|
|
*/
|
2023-06-11 14:15:46 +02:00
|
|
|
#[ORM\OneToMany(targetEntity: \App\Entity\Attachments\LabelAttachment::class, mappedBy: 'element', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
2023-05-28 01:33:45 +02:00
|
|
|
#[ORM\OrderBy(['name' => 'ASC'])]
|
2023-04-15 22:25:03 +02:00
|
|
|
protected Collection $attachments;
|
2020-04-11 17:34:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var LabelOptions
|
|
|
|
*/
|
2023-05-28 01:21:05 +02:00
|
|
|
#[Assert\Valid]
|
2023-05-28 01:33:45 +02:00
|
|
|
#[ORM\Embedded(class: 'LabelOptions')]
|
2022-09-18 22:59:31 +02:00
|
|
|
protected LabelOptions $options;
|
2020-04-11 17:34:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string The comment info for this element
|
|
|
|
*/
|
2023-05-28 01:33:45 +02:00
|
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
|
2022-09-18 22:59:31 +02:00
|
|
|
protected string $comment = '';
|
2020-04-11 17:34:01 +02:00
|
|
|
|
2020-05-02 19:47:31 +02:00
|
|
|
/**
|
2020-08-21 21:36:22 +02:00
|
|
|
* @var bool determines, if this label profile should be shown in the dropdown quick menu
|
2020-05-02 19:47:31 +02:00
|
|
|
*/
|
2023-05-28 01:33:45 +02:00
|
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
2022-09-18 22:59:31 +02:00
|
|
|
protected bool $show_in_dropdown = true;
|
2020-05-02 19:47:31 +02:00
|
|
|
|
2020-04-11 17:34:01 +02:00
|
|
|
public function __construct()
|
|
|
|
{
|
2023-05-28 01:33:45 +02:00
|
|
|
$this->attachments = new \Doctrine\Common\Collections\ArrayCollection();
|
2020-04-11 17:34:01 +02:00
|
|
|
parent::__construct();
|
|
|
|
$this->options = new LabelOptions();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOptions(): LabelOptions
|
|
|
|
{
|
|
|
|
return $this->options;
|
|
|
|
}
|
|
|
|
|
2020-05-10 21:39:31 +02:00
|
|
|
public function setOptions(LabelOptions $labelOptions): self
|
2020-05-10 13:28:01 +02:00
|
|
|
{
|
|
|
|
$this->options = $labelOptions;
|
2020-05-10 21:39:31 +02:00
|
|
|
|
2020-05-10 13:28:01 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:34:01 +02:00
|
|
|
/**
|
|
|
|
* Get the comment of the element.
|
2020-05-10 21:39:31 +02:00
|
|
|
*
|
2020-04-11 17:34:01 +02:00
|
|
|
* @return string the comment
|
|
|
|
*/
|
|
|
|
public function getComment(): ?string
|
|
|
|
{
|
|
|
|
return $this->comment;
|
|
|
|
}
|
|
|
|
|
2020-08-21 22:43:37 +02:00
|
|
|
public function setComment(string $new_comment): self
|
2020-04-11 17:34:01 +02:00
|
|
|
{
|
|
|
|
$this->comment = $new_comment;
|
2020-05-10 21:39:31 +02:00
|
|
|
|
2020-04-11 17:34:01 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2020-05-02 19:47:31 +02:00
|
|
|
/**
|
|
|
|
* Returns true, if this label profile should be shown in label generator quick menu.
|
|
|
|
*/
|
|
|
|
public function isShowInDropdown(): bool
|
|
|
|
{
|
|
|
|
return $this->show_in_dropdown;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the show in dropdown menu.
|
|
|
|
*/
|
2020-05-10 21:39:31 +02:00
|
|
|
public function setShowInDropdown(bool $show_in_dropdown): self
|
2020-05-02 19:47:31 +02:00
|
|
|
{
|
|
|
|
$this->show_in_dropdown = $show_in_dropdown;
|
2020-05-10 21:39:31 +02:00
|
|
|
|
2020-05-02 19:47:31 +02:00
|
|
|
return $this;
|
|
|
|
}
|
2020-05-10 21:39:31 +02:00
|
|
|
}
|