*/ #[ORM\OneToMany(mappedBy: 'configuration', targetEntity: PlatformOffer::class, orphanRemoval: true)] #[ORM\OrderBy(['price' => 'ASC'])] private Collection $offers; /** * Associative array to store parameters. * * @var array> */ #[ORM\Column(type: 'json')] private array $configuration = []; public function __construct() { $this->offers = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getType(): ConfigurationType { return $this->type; } public function setType(ConfigurationType $type): self { $this->type = $type; return $this; } /** * @return array> */ public function getConfiguration(): array { return $this->configuration; } /** * @param array> $configuration */ public function setConfiguration(array $configuration): self { $this->configuration = $configuration; return $this; } public static function getInstanceConfiguration(): Configuration { return (new self())->setType(ConfigurationType::INSTANCE); } /** end of basic getters and setters ------------------------------------------------ */ /** * @return array */ public function getGlobals(): array { /** @var array $globals */ $globals = $this->configuration['global'] ?? []; return $globals; } public function getPlatformName(): string { $globals = $this->getGlobals(); return (string) ($globals['globalName'] ?? ''); } public function getServicesEnabled(): bool { $globals = $this->getGlobals(); return (bool) $globals['globalServicesEnabled']; } public function getPaidMembership(): bool { $globals = $this->getGlobals(); return (bool) $globals['globalPaidMembership']; } /** * @return array */ public function getNotificationsSender(): array { /** @var array $notificationsSender */ $notificationsSender = $this->configuration['notificationsSender'] ?? []; return $notificationsSender; } public function getNotificationsSenderEmail(): string { $notificationsSender = $this->getNotificationsSender(); return $notificationsSender['notificationsSenderEmail'] ?? ''; } public function getNotificationsSenderName(): string { $notificationsSender = $this->getNotificationsSender(); return $notificationsSender['notificationsSenderName'] ?? ''; } /** * @return array */ public function getContactInformations(): array { /** @var array $contactInfo */ $contactInfo = $this->configuration['contact'] ?? []; return $contactInfo; } public function getContactEnabled(): bool { /** @var array $contactEnabled */ $contactEnabled = $this->getContactInformations(); return $contactEnabled['contactFormEnabled']; } public function getContactEmail(): string { /** @var array $contactEnabled */ $contactEnabled = $this->getContactInformations(); return $contactEnabled['contactFormEmail']; } public function isConversationAdminAccessible(): bool { /** @var array $config */ $config = $this->configuration['confidentiality'] ?? []; return $config['confidentialityConversationAdminAccess']; } public function isGroupsCreationForAll(): bool { return $this->configuration['groups']['groupsCreationMode'] === ParametersFormCommand::ALL; } // for test only public function setGroupsCreationModeToAdminOnly(): self { $this->configuration['groups']['groupsCreationMode'] = ParametersFormCommand::ONLY_ADMIN; return $this; } }