forked from mirror/Part-DB.Part-DB-server
246 lines
5.8 KiB
PHP
246 lines
5.8 KiB
PHP
<?php
|
|
/**
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
|
*
|
|
* Copyright (C) 2019 - 2020 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/>.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Entity\Parts;
|
|
|
|
use App\Entity\Attachments\CategoryAttachment;
|
|
use App\Entity\Base\AbstractPartsContainingDBElement;
|
|
use App\Entity\Parameters\CategoryParameter;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
/**
|
|
* Class AttachmentType.
|
|
*
|
|
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
|
* @ORM\Table(name="`categories`")
|
|
*/
|
|
class Category extends AbstractPartsContainingDBElement
|
|
{
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
|
|
*/
|
|
protected $children;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="Category", inversedBy="children")
|
|
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
|
*/
|
|
protected $parent;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="Part", mappedBy="category", fetch="EXTRA_LAZY")
|
|
*/
|
|
protected $parts;
|
|
|
|
/**
|
|
* @var string
|
|
* @ORM\Column(type="text")
|
|
*/
|
|
protected $partname_hint = '';
|
|
|
|
/**
|
|
* @var string
|
|
* @ORM\Column(type="text")
|
|
*/
|
|
protected $partname_regex = '';
|
|
|
|
/**
|
|
* @var bool
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
protected $disable_footprints = false;
|
|
|
|
/**
|
|
* @var bool
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
protected $disable_manufacturers = false;
|
|
|
|
/**
|
|
* @var bool
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
protected $disable_autodatasheets = false;
|
|
|
|
/**
|
|
* @var bool
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
protected $disable_properties = false;
|
|
|
|
/**
|
|
* @var string
|
|
* @ORM\Column(type="text")
|
|
*/
|
|
protected $default_description = '';
|
|
|
|
/**
|
|
* @var string
|
|
* @ORM\Column(type="text")
|
|
*/
|
|
protected $default_comment = '';
|
|
/**
|
|
* @var Collection|CategoryAttachment[]
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\CategoryAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
|
|
* @Assert\Valid()
|
|
*/
|
|
protected $attachments;
|
|
|
|
/** @var CategoryParameter[]
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\CategoryParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
|
|
* @Assert\Valid()
|
|
*/
|
|
protected $parameters;
|
|
|
|
/**
|
|
* Returns the ID as an string, defined by the element class.
|
|
* This should have a form like P000014, for a part with ID 14.
|
|
*
|
|
* @return string The ID as a string;
|
|
*/
|
|
public function getIDString(): string
|
|
{
|
|
return 'C'.sprintf('%09d', $this->getID());
|
|
}
|
|
|
|
public function getPartnameHint(): string
|
|
{
|
|
return $this->partname_hint;
|
|
}
|
|
|
|
/**
|
|
* @return Category
|
|
*/
|
|
public function setPartnameHint(string $partname_hint): self
|
|
{
|
|
$this->partname_hint = $partname_hint;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPartnameRegex(): string
|
|
{
|
|
return $this->partname_regex;
|
|
}
|
|
|
|
/**
|
|
* @return Category
|
|
*/
|
|
public function setPartnameRegex(string $partname_regex): self
|
|
{
|
|
$this->partname_regex = $partname_regex;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isDisableFootprints(): bool
|
|
{
|
|
return $this->disable_footprints;
|
|
}
|
|
|
|
/**
|
|
* @return Category
|
|
*/
|
|
public function setDisableFootprints(bool $disable_footprints): self
|
|
{
|
|
$this->disable_footprints = $disable_footprints;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isDisableManufacturers(): bool
|
|
{
|
|
return $this->disable_manufacturers;
|
|
}
|
|
|
|
/**
|
|
* @return Category
|
|
*/
|
|
public function setDisableManufacturers(bool $disable_manufacturers): self
|
|
{
|
|
$this->disable_manufacturers = $disable_manufacturers;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isDisableAutodatasheets(): bool
|
|
{
|
|
return $this->disable_autodatasheets;
|
|
}
|
|
|
|
/**
|
|
* @return Category
|
|
*/
|
|
public function setDisableAutodatasheets(bool $disable_autodatasheets): self
|
|
{
|
|
$this->disable_autodatasheets = $disable_autodatasheets;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isDisableProperties(): bool
|
|
{
|
|
return $this->disable_properties;
|
|
}
|
|
|
|
/**
|
|
* @return Category
|
|
*/
|
|
public function setDisableProperties(bool $disable_properties): self
|
|
{
|
|
$this->disable_properties = $disable_properties;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDefaultDescription(): string
|
|
{
|
|
return $this->default_description;
|
|
}
|
|
|
|
/**
|
|
* @return Category
|
|
*/
|
|
public function setDefaultDescription(string $default_description): self
|
|
{
|
|
$this->default_description = $default_description;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDefaultComment(): string
|
|
{
|
|
return $this->default_comment;
|
|
}
|
|
|
|
/**
|
|
* @return Category
|
|
*/
|
|
public function setDefaultComment(string $default_comment): self
|
|
{
|
|
$this->default_comment = $default_comment;
|
|
|
|
return $this;
|
|
}
|
|
}
|