. */ declare(strict_types=1); namespace App\Entity\Base; use App\Entity\Contracts\NamedElementInterface; use App\Entity\Contracts\TimeStampableInterface; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; /** * All subclasses of this class have an attribute "name". * * @ORM\MappedSuperclass(repositoryClass="App\Repository\NamedDBElement") * @ORM\HasLifecycleCallbacks() */ abstract class AbstractNamedDBElement extends AbstractDBElement implements NamedElementInterface, TimeStampableInterface { use TimestampTrait; /** * @var string the name of this element * @ORM\Column(type="string") * @Assert\NotBlank() * @Groups({"simple", "extended", "full"}) */ protected $name = ''; /****************************************************************************** * * Helpers * ******************************************************************************/ public function __toString() { return $this->getName(); } public function __clone() { if ($this->id) { //We create a new object, so give it a new creation date $this->addedDate = null; } parent::__clone(); // TODO: Change the autogenerated stub } /******************************************************************************** * * Getters * *********************************************************************************/ /** * Get the name of this element. * * @return string the name of this element */ public function getName(): string { return $this->name; } /******************************************************************************** * * Setters * *********************************************************************************/ /** * Change the name of this element. * * @param string $new_name the new name */ public function setName(string $new_name): self { $this->name = $new_name; return $this; } }