*/ #[ORM\Column(name: 'columns', type: Types::JSON, nullable: false)] #[Assert\Count(min: 1)] #[Assert\NotNull] private array $columns = []; /** * @var array */ #[ORM\Column(name: 'options', type: Types::JSON, nullable: false)] #[Assert\NotNull] private array $options = []; public function getId(): ?int { return $this->id; } public function isNew(): bool { return $this->id === null; } public function setTitle(?string $title): void { $this->title = $title; } public function getTitle(): ?string { return $this->title; } public function setRenderer(string $renderer): void { $this->renderer = $renderer; } public function getRenderer(): string { return $this->renderer; } public function getLanguage(): ?string { return $this->language; } public function setLanguage(?string $language): void { $this->language = $language; } /** * @return array */ public function getColumns(): array { return $this->columns; } /** * @param array|null $columns */ public function setColumns(?array $columns): void { $this->columns = $columns ?? []; } public function getOption(string $key, int|string|bool|null $default): int|string|bool|null { if (\array_key_exists($key, $this->options)) { return $this->options[$key] ?? $default; } return $default; } public function setOption(string $key, int|string|bool|null $value): void { if ($value === null) { if (\array_key_exists($key, $this->options)) { unset($this->options[$key]); } return; } $this->options[$key] = $value; } /** * @return array */ public function getOptions(): array { return $this->options; } /** * @param array $options */ public function setOptions(?array $options): void { $this->options = $options ?? []; } /** * Only used for CSV export */ public function setSeparator(string $separator): void { if (!\in_array($separator, [',', ';'], true)) { throw new \InvalidArgumentException('Invalid separator, comma and semicolon are allowed.'); } $this->setOption('separator', $separator); } public function getSeparator(): string { return (string) $this->getOption('separator', ','); } /** * Only used for PDF export */ public function setName(?string $name): void { $this->setOption('name', $name); } public function getName(): ?string { $name = $this->getOption('name', null); return \is_string($name) ? $name : null; } /** * Only used for PDF export */ public function setPageSize(?string $pageSize): void { $this->setOption('pageSize', $pageSize); } public function getPageSize(): ?string { $pageSize = $this->getOption('pageSize', null); return \is_string($pageSize) ? $pageSize : null; } /** * Only used for PDF export */ public function setOrientation(?string $orientation): void { if ($orientation !== null) { $orientation = strtolower($orientation); if (!\in_array($orientation, ['landscape', 'portrait'], true)) { throw new \InvalidArgumentException('Invalid orientation. Allowed values are "landscape" and "portrait".'); } } $this->setOption('orientation', $orientation); } public function getOrientation(): ?string { $orientation = $this->getOption('orientation', null); return \is_string($orientation) ? $orientation : null; } /** * Only used for PDF export * @param array $columns */ public function setSummaryColumns(array $columns): void { $columns = \count($columns) > 0 ? implode(',', $columns) : null; $this->setOption('summary_columns', $columns); } /** * @return array */ public function getSummaryColumns(): array { $columns = $this->getOption('summary_columns', null); if (!\is_string($columns)) { return []; } return explode(',', $columns); } /** * Only used for PDF export */ public function setFont(?string $font): void { $this->setOption('font', $font); } public function getFont(): ?string { $font = $this->getOption('font', null); return \is_string($font) ? $font : null; } public function __toString(): string { return $this->title ?? 'New'; } public function __clone() { if ($this->id) { $this->id = null; } } }