name); */ return $this->name; } /** * Returns the last time when the element was modified. * Returns null if the element was not yet saved to DB yet. * * @return \DateTime|null The time of the last edit. */ public function getLastModified(): ?\DateTime { return $this->lastModified; } /** * Returns the date/time when the element was created. * Returns null if the element was not yet saved to DB yet. * * @return \DateTime|null The creation time of the part. */ public function getAddedDate(): ?\DateTime { return $this->addedDate; } /******************************************************************************** * * Setters * *********************************************************************************/ /** * Change the name of this element. * * Spaces at the begin and at the end of the string will be removed * automatically in NamedDBElement::check_values_validity(). * So you don't have to do this yourself. * * @param string $new_name the new name * * @return self */ public function setName(string $new_name): self { $this->name = $new_name; return $this; } /****************************************************************************** * * Helpers * ******************************************************************************/ /** * Helper for updating the timestamp. It is automatically called by doctrine before persisting. * * @ORM\PrePersist * @ORM\PreUpdate */ public function updatedTimestamps(): void { $this->lastModified = new \DateTime('now'); if (null === $this->addedDate) { $this->addedDate = new \DateTime('now'); } } public function __toString() { return $this->getName(); } }