* @ORM\OneToMany( * targetEntity="Chill\CustomFieldsBundle\Entity\CustomField", * mappedBy="customFieldGroup") * @ORM\OrderBy({"ordering": "ASC"}) */ private Collection $customFields; /** * @var string * * @ORM\Column(type="string", length=255) */ private ?string $entity = null; /** * @var int * * @ORM\Id * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ private ?int $id = null; /** * @var array * * @ORM\Column(type="json") */ private $name; /** * @ORM\Column(type="json") */ private array $options = []; /** * CustomFieldsGroup constructor. */ public function __construct() { $this->customFields = new ArrayCollection(); } /** * Add customField. * * @return CustomFieldsGroup */ public function addCustomField(CustomField $customField) { $this->customFields[] = $customField; return $this; } /** * Get all the custom. */ public function getActiveCustomFields(): array { if (null === $this->activeCustomFields) { $this->activeCustomFields = []; foreach ($this->customFields as $cf) { if ($cf->isActive()) { $this->activeCustomFields[] = $cf; } } } return $this->activeCustomFields; } /** * @return Collection */ public function getCustomFields() { return $this->customFields; } /** * Get entity. * * @return string */ public function getEntity() { return $this->entity; } /** * Get id. * * @return int */ public function getId() { return $this->id; } /** * Get name. */ public function getName(?string $language = null): array|string { //TODO set this in a service, PLUS twig function if (null !== $language) { if (isset($this->name[$language])) { return $this->name[$language]; } foreach ($this->name as $name) { if (!empty($name)) { return $name; } } return ''; } return $this->name; } /** * get options array. * * @return array */ public function getOptions() { return $this->options; } /** * Remove customField. */ public function removeCustomField(CustomField $customField) { $this->customFields->removeElement($customField); } /** * Set entity. * * @param string $entity * * @return CustomFieldsGroup */ public function setEntity($entity) { $this->entity = $entity; return $this; } /** * Set name. * * @param array $name * * @return CustomFieldsGroup */ public function setName($name) { $this->name = $name; return $this; } /** * set options array. * * @return CustomFieldsGroup */ public function setOptions(array $options) { $this->options = $options; return $this; } }