src/Entity/JournalView.php line 33
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM,
Doctrine\DBAL\Types\Types;
use Symfony\Component\Serializer\Annotation\Groups,
Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Metadata\ApiProperty,
ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\Get;
use App\Entity\Trait\IdTrait,
App\Entity\Trait\UuidTrait,
App\Repository\JournalViewRepository;
use App\Doctrine\DBAL\Types\AuthorPropertiesType,
App\Enum\JournalAffiliationLogoType,
App\Enum\JournalColorAccent,
App\Enum\AlertType,
App\Enum\JournalPageTemplate,
App\Enum\JournalCoverType,
App\Enum\Font,
App\Enum\AuthorProperty;
#[ApiResource(
security: 'is_granted("' . Journal::class . '")',
operations: [ new Get() ],
extraProperties: ['standard_put' => false],
)]
#[ORM\Entity(repositoryClass: JournalViewRepository::class)]
class JournalView
{
use IdTrait,
UuidTrait;
#[ApiProperty(description: 'Parent')]
#[ORM\OneToOne(targetEntity: Journal::class, inversedBy: 'view')]
#[ORM\JoinColumn(onDelete: 'cascade', nullable: false)]
private Journal $parent;
#[ApiProperty(description: 'Cover type', writableLink: false)]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(
type: Types::STRING,
enumType: JournalCoverType::class,
length: 255,
options: ['default' => JournalCoverType::CURRENT_ISSUE]
)]
private JournalCoverType $coverType = JournalCoverType::CURRENT_ISSUE;
#[ApiProperty(description: 'Template', writableLink: false)]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(
type: Types::STRING,
enumType: JournalPageTemplate::class,
length: 255,
options: ['default' => JournalPageTemplate::TEMPLATE_1]
)]
private JournalPageTemplate $template = JournalPageTemplate::TEMPLATE_1;
#[ApiProperty(description: 'Is affiliation visible in header')]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => true])]
private bool $isAffiliationVisibleInHeader = true;
#[ApiProperty(description: 'Alert A: is visible')]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $alertAIsVisible = false;
#[ApiProperty(description: 'Alert A: type', writableLink: false)]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(
type: Types::STRING,
enumType: AlertType::class,
length: 255,
options: ['default' => AlertType::ALERT]
)]
private AlertType $alertAType = AlertType::ALERT;
#[ApiProperty(description: 'Alert A: is take off active')]
#[Groups(['read:' . Journal::class, 'write'])]
// #[Assert\Expression(
// expression: '! value || this.getAlertATakeOffDateTime()',
// message: 'Take off date time must be set before activating.'
// )]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $alertAIsTakeOffActive = false;
#[ApiProperty(description: 'Alert A: take off date and time')]
#[Groups(['read:' . Journal::class, 'write'])]
// #[Assert\GreaterThan('tomorrow')]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $alertATakeOffDateTime = null;
#[ApiProperty(description: 'Alert B: is visible')]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $alertBIsVisible = false;
#[ApiProperty(description: 'Alert B: type', writableLink: false)]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(
type: Types::STRING,
enumType: AlertType::class,
length: 255,
options: ['default' => AlertType::ALERT]
)]
private AlertType $alertBType = AlertType::ALERT;
#[ApiProperty(description: 'Alert B: is take off active')]
#[Groups(['read:' . Journal::class, 'write'])]
// #[Assert\Expression(
// expression: '! value || this.getAlertBTakeOffDateTime()',
// message: 'Take off date time must be set before activating.'
// )]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $alertBIsTakeOffActive = false;
#[ApiProperty(description: 'Alert B: take off date and time')]
#[Groups(['read:' . Journal::class, 'write'])]
// #[Assert\GreaterThan('tomorrow')]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $alertBTakeOffDateTime = null;
#[ApiProperty(description: 'Has badge')]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $hasBadge = false;
#[ApiProperty(description: 'Affiliation logo type', writableLink: false)]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(
type: Types::STRING,
enumType: JournalAffiliationLogoType::class,
length: 255,
options: ['default' => JournalAffiliationLogoType::HIDDEN]
)]
private JournalAffiliationLogoType $affiliationLogoType = JournalAffiliationLogoType::HIDDEN;
#[ApiProperty(description: 'Header background color')]
#[Groups(['read:' . Journal::class, 'write'])]
#[Assert\NotNull]
#[Assert\CssColor]
#[ORM\Column(type: Types::STRING, length: 255, options: ['default' => '#5E9959'])]
private string $headerBgColor = '#5E9959';
#[ApiProperty(description: 'Header text color')]
#[Groups(['read:' . Journal::class, 'write'])]
#[Assert\NotNull]
#[Assert\CssColor]
#[ORM\Column(type: Types::STRING, length: 255, options: ['default' => '#fff'])]
private string $headerTextColor = '#fff';
#[ApiProperty(description: 'Header text font', writableLink: false)]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(
type: Types::STRING,
enumType: Font::class,
length: 255,
options: ['default' => Font::ARIAL]
)]
private Font $headerTextFont = Font::ARIAL;
#[ApiProperty(description: 'Menu background color')]
#[Groups(['read:' . Journal::class, 'write'])]
#[Assert\NotNull]
#[Assert\CssColor]
#[ORM\Column(type: Types::STRING, length: 255, options: ['default' => '#000'])]
private string $menuBgColor = '#000';
#[ApiProperty(description: 'Menu text color')]
#[Groups(['read:' . Journal::class, 'write'])]
#[Assert\NotNull]
#[Assert\CssColor]
#[ORM\Column(type: Types::STRING, length: 255, options: ['default' => '#fff'])]
private string $menuTextColor = '#fff';
#[ApiProperty(description: 'Menu text font', writableLink: false)]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(
type: Types::STRING,
enumType: Font::class,
length: 255,
options: ['default' => Font::ARIAL]
)]
private Font $menuTextFont = Font::ARIAL;
#[ApiProperty(description: 'Submenu background color')]
#[Groups(['read:' . Journal::class, 'write'])]
#[Assert\CssColor]
#[ORM\Column(type: Types::STRING, length: 255, options: ['default' => '#000'])]
private string $submenuBgColor = '#000';
#[ApiProperty(description: 'Submenu text color')]
#[Groups(['read:' . Journal::class, 'write'])]
#[Assert\CssColor]
#[ORM\Column(type: Types::STRING, length: 255, options: ['default' => '#fff'])]
private string $submenuTextColor = '#fff';
#[ApiProperty(description: 'Submenu text font', writableLink: false)]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(
type: Types::STRING,
enumType: Font::class,
length: 255,
options: ['default' => Font::ARIAL]
)]
private Font $submenuTextFont = Font::ARIAL;
#[ApiProperty(description: 'Color accent', writableLink: false)]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(type: Types::STRING, enumType: JournalColorAccent::class, length: 255, nullable: true)]
private ?JournalColorAccent $colorAccent = null;
#[ApiProperty(description: 'Visible editorial group member properties', writableLink: false)]
#[Groups(['read:' . Journal::class, 'write'])]
#[Assert\Choice(callback: [AuthorProperty::class, 'cases'], multiple: true)]
#[Assert\Unique]
#[Assert\Count(min: 1)]
#[ORM\Column(type: AuthorPropertiesType::NAME)]
private array $visibleEditorialGroupMemberProperties = [
AuthorProperty::PREFIX,
AuthorProperty::NAME,
AuthorProperty::SURNAME,
AuthorProperty::AFFILIATION
];
#[ApiProperty(description: 'Visible scientific council member properties', writableLink: false)]
#[Groups(['read:' . Journal::class, 'write'])]
#[Assert\Choice(callback: [AuthorProperty::class, 'cases'], multiple: true)]
#[Assert\Unique]
#[Assert\Count(min: 1)]
#[ORM\Column(type: AuthorPropertiesType::NAME)]
private array $visibleScientificCouncilMemberProperties = [
AuthorProperty::PREFIX,
AuthorProperty::NAME,
AuthorProperty::SURNAME,
AuthorProperty::AFFILIATION
];
#[ApiProperty(description: 'Is editorial groups visible in volumes and numbers')]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => true])]
private bool $isEditorialGroupsVisibleInVolumesAndNumbers = true;
#[ApiProperty(description: 'Is footer column A visible')]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $isFooterColumnAVisible = false;
#[ApiProperty(description: 'Is footer column B visible')]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $isFooterColumnBVisible = false;
#[ApiProperty(description: 'Is footer column C visible')]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $isFooterColumnCVisible = false;
#[ApiProperty(description: 'Is footer column D visible')]
#[Groups(['read:' . Journal::class, 'write'])]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $isFooterColumnDVisible = false;
public function __construct(Journal $parent)
{
$this->setUuid();
$this->parent = $parent;
}
public function getParent(): Journal
{
return $this->parent;
}
public function getCoverType(): JournalCoverType
{
return $this->coverType;
}
public function setCoverType(JournalCoverType $coverType): self
{
$this->coverType = $coverType;
return $this;
}
public function getTemplate(): JournalPageTemplate
{
return $this->template;
}
public function setTemplate(JournalPageTemplate $template): self
{
$this->template = $template;
return $this;
}
public function getIsAffiliationVisibleInHeader(): bool
{
return $this->isAffiliationVisibleInHeader;
}
public function setIsAffiliationVisibleInHeader(bool $isAffiliationVisibleInHeader): self
{
$this->isAffiliationVisibleInHeader = $isAffiliationVisibleInHeader;
return $this;
}
public function getAlertAIsVisible(): bool
{
return $this->alertAIsVisible;
}
public function setAlertAIsVisible(bool $alertAIsVisible): self
{
$this->alertAIsVisible = $alertAIsVisible;
return $this;
}
public function getAlertAType(): AlertType
{
return $this->alertAType;
}
public function setAlertAType(AlertType $alertAType): self
{
$this->alertAType = $alertAType;
return $this;
}
public function getAlertAIsTakeOffActive(): bool
{
return $this->alertAIsTakeOffActive;
}
public function setAlertAIsTakeOffActive(bool $alertAIsTakeOffActive): self
{
$this->alertAIsTakeOffActive = $alertAIsTakeOffActive;
return $this;
}
public function getAlertATakeOffDateTime(): ?\DateTimeInterface
{
return $this->alertATakeOffDateTime;
}
public function setAlertATakeOffDateTime(?\DateTimeInterface $alertATakeOffDateTime): self
{
$this->alertATakeOffDateTime = $alertATakeOffDateTime;
if (! $alertATakeOffDateTime) {
$this->alertAIsTakeOffActive = false;
}
return $this;
}
public function getAlertBIsVisible(): bool
{
return $this->alertBIsVisible;
}
public function setAlertBIsVisible(bool $alertBIsVisible): self
{
$this->alertBIsVisible = $alertBIsVisible;
return $this;
}
public function getAlertBType(): AlertType
{
return $this->alertBType;
}
public function setAlertBType(AlertType $alertBType): self
{
$this->alertBType = $alertBType;
return $this;
}
public function getAlertBIsTakeOffActive(): bool
{
return $this->alertBIsTakeOffActive;
}
public function setAlertBIsTakeOffActive(bool $alertBIsTakeOffActive): self
{
$this->alertBIsTakeOffActive = $alertBIsTakeOffActive;
return $this;
}
public function getAlertBTakeOffDateTime(): ?\DateTimeInterface
{
return $this->alertBTakeOffDateTime;
}
public function setAlertBTakeOffDateTime(?\DateTimeInterface $alertBTakeOffDateTime): self
{
$this->alertBTakeOffDateTime = $alertBTakeOffDateTime;
if (! $alertBTakeOffDateTime) {
$this->alertBIsTakeOffActive = false;
}
return $this;
}
private function clearAlert(string $type): self
{
$isTakeOffActive = 'alert' . strtoupper($type) . 'IsTakeOffActive';
$takeOffDateTime = 'alert' . strtoupper($type) . 'TakeOffDateTime';
if (
! $this->$isTakeOffActive
|| (new \DateTimeImmutable()) < $this->$takeOffDateTime
) {
return $this;
}
$isVisible = 'alert' . strtoupper($type) . 'IsVisible';
$this->$isVisible = false;
$this->$isTakeOffActive = false;
$this->$takeOffDateTime = null;
return $this;
}
public function clearAlerts(): self
{
$this
->clearAlert('a')
->clearAlert('b');
return $this;
}
public function getHasBadge(): bool
{
return $this->hasBadge;
}
public function setHasBadge(bool $hasBadge): self
{
$this->hasBadge = $hasBadge;
return $this;
}
public function getAffiliationLogoType(): JournalAffiliationLogoType
{
return $this->affiliationLogoType;
}
public function setAffiliationLogoType(JournalAffiliationLogoType $affiliationLogoType): self
{
$this->affiliationLogoType = $affiliationLogoType;
return $this;
}
public function getHeaderBgColor(): string
{
return $this->headerBgColor;
}
public function setHeaderBgColor(string $headerBgColor): self
{
$this->headerBgColor = $headerBgColor;
return $this;
}
public function getHeaderTextColor(): string
{
return $this->headerTextColor;
}
public function setHeaderTextColor(string $headerTextColor): self
{
$this->headerTextColor = $headerTextColor;
return $this;
}
public function getHeaderTextFont(): Font
{
return $this->headerTextFont;
}
public function setHeaderTextFont(Font $headerTextFont): self
{
$this->headerTextFont = $headerTextFont;
return $this;
}
public function getMenuBgColor(): string
{
return $this->menuBgColor;
}
public function setMenuBgColor(string $menuBgColor): self
{
$this->menuBgColor = $menuBgColor;
return $this;
}
public function getMenuTextColor(): string
{
return $this->menuTextColor;
}
public function setMenuTextColor(string $menuTextColor): self
{
$this->menuTextColor = $menuTextColor;
return $this;
}
public function getMenuTextFont(): Font
{
return $this->menuTextFont;
}
public function setMenuTextFont(Font $menuTextFont): self
{
$this->menuTextFont = $menuTextFont;
return $this;
}
public function getSubmenuBgColor(): string
{
return $this->submenuBgColor;
}
public function setSubmenuBgColor(string $submenuBgColor): self
{
$this->submenuBgColor = $submenuBgColor;
return $this;
}
public function getSubmenuTextColor(): string
{
return $this->submenuTextColor;
}
public function setSubmenuTextColor(string $submenuTextColor): self
{
$this->submenuTextColor = $submenuTextColor;
return $this;
}
public function getSubmenuTextFont(): Font
{
return $this->submenuTextFont;
}
public function setSubmenuTextFont(Font $submenuTextFont): self
{
$this->submenuTextFont = $submenuTextFont;
return $this;
}
public function getColorAccent(): ?JournalColorAccent
{
return $this->colorAccent;
}
public function setColorAccent(?JournalColorAccent $colorAccent): self
{
$this->colorAccent = $colorAccent;
return $this;
}
public function getVisibleEditorialGroupMemberProperties(): array
{
return $this->visibleEditorialGroupMemberProperties;
}
public function setVisibleEditorialGroupMemberProperties(array $visibleEditorialGroupMemberProperties): self
{
$this->visibleEditorialGroupMemberProperties = $visibleEditorialGroupMemberProperties;
return $this;
}
public function getVisibleScientificCouncilMemberProperties(): array
{
return $this->visibleScientificCouncilMemberProperties;
}
public function setVisibleScientificCouncilMemberProperties(array $visibleScientificCouncilMemberProperties): self
{
$this->visibleScientificCouncilMemberProperties = $visibleScientificCouncilMemberProperties;
return $this;
}
public function getIsEditorialGroupsVisibleInVolumesAndNumbers(): bool
{
return $this->isEditorialGroupsVisibleInVolumesAndNumbers;
}
public function setIsEditorialGroupsVisibleInVolumesAndNumbers(bool $isEditorialGroupsVisibleInVolumesAndNumbers): self
{
$this->isEditorialGroupsVisibleInVolumesAndNumbers = $isEditorialGroupsVisibleInVolumesAndNumbers;
return $this;
}
public function getIsFooterColumnAVisible(): bool
{
return $this->isFooterColumnAVisible;
}
public function setIsFooterColumnAVisible(bool $isFooterColumnAVisible): self
{
$this->isFooterColumnAVisible = $isFooterColumnAVisible;
return $this;
}
public function getIsFooterColumnBVisible(): bool
{
return $this->isFooterColumnBVisible;
}
public function setIsFooterColumnBVisible(bool $isFooterColumnBVisible): self
{
$this->isFooterColumnBVisible = $isFooterColumnBVisible;
return $this;
}
public function getIsFooterColumnCVisible(): bool
{
return $this->isFooterColumnCVisible;
}
public function setIsFooterColumnCVisible(bool $isFooterColumnCVisible): self
{
$this->isFooterColumnCVisible = $isFooterColumnCVisible;
return $this;
}
public function getIsFooterColumnDVisible(): bool
{
return $this->isFooterColumnDVisible;
}
public function setIsFooterColumnDVisible(bool $isFooterColumnDVisible): self
{
$this->isFooterColumnDVisible = $isFooterColumnDVisible;
return $this;
}
public function clone(Journal $parent): self
{
$clone = clone $this;
$clone->id = null;
$clone->setUuid();
$clone->alertATakeOffDateTime = null;
$clone->alertAIsTakeOffActive = false;
$clone->alertBTakeOffDateTime = null;
$clone->alertBIsTakeOffActive = false;
$clone->parent = $parent;
return $clone;
}
}