src/Entity/Embeddables/DateTimeRichField.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Embeddables;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Embeddable()
  6.  */
  7. class DateTimeRichField extends AbstractRichField implements RichFieldInterface
  8. {
  9.     /**
  10.      * @var string | null
  11.      *
  12.      * @ORM\Column(type="datetime", nullable=true)
  13.      */
  14.     protected $value;
  15.     /**
  16.      * @var string | null
  17.      *
  18.      * @ORM\Column(type="string", nullable=true)
  19.      */
  20.     protected $backgroundColor;
  21.     /**
  22.      * @var string | null
  23.      *
  24.      * @ORM\Column(type="string", nullable=true)
  25.      */
  26.     protected $textColor;
  27.     public function __toString()
  28.     {
  29.         if ($this->value instanceof \DateTime) {
  30.             return $this->value->format('Y-m-d');
  31.         }
  32.         return (string)$this->value;
  33.     }
  34. }