<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\UniqueConstraint;
use EightMarq\CoreComponent\Entity\BaseEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table(name="predefined_colors", uniqueConstraints={
* @UniqueConstraint(columns={"background_color", "text_color"})
* })
*
* @UniqueEntity(fields={"backgroundColor", "textColor"}, errorPath="backgroundColor", message="error.entity.not_unique")
*
* @ORM\Entity(repositoryClass="App\Repository\PredefinedColorRepository")
*
*/
class PredefinedColor extends BaseEntity
{
/**
* @var string | null
*
* @ORM\Column(type="string")
*
* FormField(type="Symfony\Component\Form\Extension\Core\Type\ColorType", options={"label": "form.label_background_color"})
*
* ListField(
* fieldDescriptionOptions={"label": "list.label_background_color", "template": "admin/fields/color_field.html.twig"}
* )
*
* DatagridField(
* fieldDescriptionOptions={"label": "filter.label_background_color"}
* )
*
* @Assert\NotBlank()
*/
protected $backgroundColor;
/**
* @var string | null
*
* @ORM\Column(type="string")
*
* FormField(type="Symfony\Component\Form\Extension\Core\Type\ColorType", options={"label": "form.label_text_color"})
*
* ListField(
* fieldDescriptionOptions={"label": "list.label_text_color", "template": "admin/fields/color_field.html.twig"}
* )
*
* DatagridField(
* fieldDescriptionOptions={"label": "filter.label_text_color"}
* )
*
* @Assert\NotBlank()
*/
protected $textColor;
/**
* @var string
*
* ListField(
* fieldDescriptionOptions={"label": "list.label_example", "template": "admin/fields/color_field_example.html.twig"}
* )
*/
protected $example = 'rich_field.example';
public function __toString()
{
return $this->getBackgroundColor() ?? '';
}
/**
* @return string|null
*/
public function getBackgroundColor(): ?string
{
return $this->backgroundColor;
}
/**
* @param string|null $backgroundColor
*/
public function setBackgroundColor(?string $backgroundColor): void
{
$this->backgroundColor = $backgroundColor;
}
/**
* @return string|null
*/
public function getTextColor(): ?string
{
return $this->textColor;
}
/**
* @param string|null $textColor
*/
public function setTextColor(?string $textColor): void
{
$this->textColor = $textColor;
}
/**
* @return string
*/
public function getExample(): string
{
return $this->example;
}
/**
* @param string $example
*/
public function setExample(string $example): void
{
$this->example = $example;
}
}