src/Entity/PredefinedColor.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\ORM\Mapping\UniqueConstraint;
  5. use EightMarq\CoreComponent\Entity\BaseEntity;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Table(name="predefined_colors", uniqueConstraints={
  10.  *     @UniqueConstraint(columns={"background_color", "text_color"})
  11.  * })
  12.  *
  13.  * @UniqueEntity(fields={"backgroundColor", "textColor"}, errorPath="backgroundColor", message="error.entity.not_unique")
  14.  *
  15.  * @ORM\Entity(repositoryClass="App\Repository\PredefinedColorRepository")
  16.  *
  17.  */
  18. class PredefinedColor extends BaseEntity
  19. {
  20.     /**
  21.      * @var string | null
  22.      *
  23.      * @ORM\Column(type="string")
  24.      *
  25.      * FormField(type="Symfony\Component\Form\Extension\Core\Type\ColorType", options={"label": "form.label_background_color"})
  26.      *
  27.      * ListField(
  28.      *     fieldDescriptionOptions={"label": "list.label_background_color", "template": "admin/fields/color_field.html.twig"}
  29.      * )
  30.      *
  31.      * DatagridField(
  32.      *     fieldDescriptionOptions={"label": "filter.label_background_color"}
  33.      * )
  34.      *
  35.      * @Assert\NotBlank()
  36.      */
  37.     protected $backgroundColor;
  38.     /**
  39.      * @var string | null
  40.      *
  41.      * @ORM\Column(type="string")
  42.      *
  43.      * FormField(type="Symfony\Component\Form\Extension\Core\Type\ColorType", options={"label": "form.label_text_color"})
  44.      *
  45.      * ListField(
  46.      *     fieldDescriptionOptions={"label": "list.label_text_color", "template": "admin/fields/color_field.html.twig"}
  47.      * )
  48.      *
  49.      * DatagridField(
  50.      *     fieldDescriptionOptions={"label": "filter.label_text_color"}
  51.      * )
  52.      *
  53.      * @Assert\NotBlank()
  54.      */
  55.     protected $textColor;
  56.     /**
  57.      * @var string
  58.      *
  59.      * ListField(
  60.      *     fieldDescriptionOptions={"label": "list.label_example", "template": "admin/fields/color_field_example.html.twig"}
  61.      * )
  62.      */
  63.     protected $example 'rich_field.example';
  64.     public function __toString()
  65.     {
  66.         return $this->getBackgroundColor() ?? '';
  67.     }
  68.     /**
  69.      * @return string|null
  70.      */
  71.     public function getBackgroundColor(): ?string
  72.     {
  73.         return $this->backgroundColor;
  74.     }
  75.     /**
  76.      * @param string|null $backgroundColor
  77.      */
  78.     public function setBackgroundColor(?string $backgroundColor): void
  79.     {
  80.         $this->backgroundColor $backgroundColor;
  81.     }
  82.     /**
  83.      * @return string|null
  84.      */
  85.     public function getTextColor(): ?string
  86.     {
  87.         return $this->textColor;
  88.     }
  89.     /**
  90.      * @param string|null $textColor
  91.      */
  92.     public function setTextColor(?string $textColor): void
  93.     {
  94.         $this->textColor $textColor;
  95.     }
  96.     /**
  97.      * @return string
  98.      */
  99.     public function getExample(): string
  100.     {
  101.         return $this->example;
  102.     }
  103.     /**
  104.      * @param string $example
  105.      */
  106.     public function setExample(string $example): void
  107.     {
  108.         $this->example $example;
  109.     }
  110. }