src/Entity/JournalView.php line 33

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM,
  4.     Doctrine\DBAL\Types\Types;
  5. use Symfony\Component\Serializer\Annotation\Groups,
  6.     Symfony\Component\Validator\Constraints as Assert;
  7. use ApiPlatform\Metadata\ApiProperty,
  8.     ApiPlatform\Metadata\ApiResource,
  9.     ApiPlatform\Metadata\Get;
  10. use App\Entity\Trait\IdTrait,
  11.     App\Entity\Trait\UuidTrait,
  12.     App\Repository\JournalViewRepository;
  13. use App\Doctrine\DBAL\Types\AuthorPropertiesType,
  14.     App\Enum\JournalAffiliationLogoType,
  15.     App\Enum\JournalColorAccent,
  16.     App\Enum\AlertType,
  17.     App\Enum\JournalPageTemplate,
  18.     App\Enum\JournalCoverType,
  19.     App\Enum\Font,
  20.     App\Enum\AuthorProperty;
  21. #[ApiResource(
  22.     security'is_granted("' Journal::class . '")',
  23.     operations: [ new Get() ],
  24.     extraProperties: ['standard_put' => false],
  25. )]
  26. #[ORM\Entity(repositoryClassJournalViewRepository::class)]
  27. class JournalView
  28. {
  29.     use IdTrait,
  30.         UuidTrait;
  31.     #[ApiProperty(description'Parent')]
  32.     #[ORM\OneToOne(targetEntityJournal::class, inversedBy'view')]
  33.     #[ORM\JoinColumn(onDelete'cascade'nullablefalse)]
  34.     private Journal $parent;
  35.     #[ApiProperty(description'Cover type'writableLinkfalse)]
  36.     #[Groups(['read:' Journal::class, 'write'])]
  37.     #[ORM\Column(
  38.         typeTypes::STRING,
  39.         enumTypeJournalCoverType::class,
  40.         length255,
  41.         options: ['default' => JournalCoverType::CURRENT_ISSUE]
  42.     )]
  43.     private JournalCoverType $coverType JournalCoverType::CURRENT_ISSUE;
  44.     #[ApiProperty(description'Template'writableLinkfalse)]
  45.     #[Groups(['read:' Journal::class, 'write'])]
  46.     #[ORM\Column(
  47.         typeTypes::STRING,
  48.         enumTypeJournalPageTemplate::class,
  49.         length255,
  50.         options: ['default' => JournalPageTemplate::TEMPLATE_1]
  51.     )]
  52.     private JournalPageTemplate $template JournalPageTemplate::TEMPLATE_1;
  53.     #[ApiProperty(description'Is affiliation visible in header')]
  54.     #[Groups(['read:' Journal::class, 'write'])]
  55.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => true])]
  56.     private bool $isAffiliationVisibleInHeader true;
  57.     #[ApiProperty(description'Alert A: is visible')]
  58.     #[Groups(['read:' Journal::class, 'write'])]
  59.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  60.     private bool $alertAIsVisible false;
  61.     #[ApiProperty(description'Alert A: type'writableLinkfalse)]
  62.     #[Groups(['read:' Journal::class, 'write'])]
  63.     #[ORM\Column(
  64.         typeTypes::STRING,
  65.         enumTypeAlertType::class,
  66.         length255,
  67.         options: ['default' => AlertType::ALERT]
  68.     )]
  69.     private AlertType $alertAType AlertType::ALERT;
  70.     #[ApiProperty(description'Alert A: is take off active')]
  71.     #[Groups(['read:' Journal::class, 'write'])]
  72.     // #[Assert\Expression(
  73.     //     expression: '! value || this.getAlertATakeOffDateTime()',
  74.     //     message: 'Take off date time must be set before activating.'
  75.     // )]
  76.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  77.     private bool $alertAIsTakeOffActive false;
  78.     #[ApiProperty(description'Alert A: take off date and time')]
  79.     #[Groups(['read:' Journal::class, 'write'])]
  80.     // #[Assert\GreaterThan('tomorrow')]
  81.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  82.     private ?\DateTimeInterface $alertATakeOffDateTime null;
  83.     #[ApiProperty(description'Alert B: is visible')]
  84.     #[Groups(['read:' Journal::class, 'write'])]
  85.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  86.     private bool $alertBIsVisible false;
  87.     #[ApiProperty(description'Alert B: type'writableLinkfalse)]
  88.     #[Groups(['read:' Journal::class, 'write'])]
  89.     #[ORM\Column(
  90.         typeTypes::STRING,
  91.         enumTypeAlertType::class,
  92.         length255,
  93.         options: ['default' => AlertType::ALERT]
  94.     )]
  95.     private AlertType $alertBType AlertType::ALERT;
  96.     #[ApiProperty(description'Alert B: is take off active')]
  97.     #[Groups(['read:' Journal::class, 'write'])]
  98.     // #[Assert\Expression(
  99.     //     expression: '! value || this.getAlertBTakeOffDateTime()',
  100.     //     message: 'Take off date time must be set before activating.'
  101.     // )]
  102.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  103.     private bool $alertBIsTakeOffActive false;
  104.     #[ApiProperty(description'Alert B: take off date and time')]
  105.     #[Groups(['read:' Journal::class, 'write'])]
  106.     // #[Assert\GreaterThan('tomorrow')]
  107.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  108.     private ?\DateTimeInterface $alertBTakeOffDateTime null;
  109.     #[ApiProperty(description'Has badge')]
  110.     #[Groups(['read:' Journal::class, 'write'])]
  111.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  112.     private bool $hasBadge false;
  113.     #[ApiProperty(description'Affiliation logo type'writableLinkfalse)]
  114.     #[Groups(['read:' Journal::class, 'write'])]
  115.     #[ORM\Column(
  116.         typeTypes::STRING,
  117.         enumTypeJournalAffiliationLogoType::class,
  118.         length255,
  119.         options: ['default' => JournalAffiliationLogoType::HIDDEN]
  120.     )]
  121.     private JournalAffiliationLogoType $affiliationLogoType JournalAffiliationLogoType::HIDDEN;
  122.     #[ApiProperty(description'Header background color')]
  123.     #[Groups(['read:' Journal::class, 'write'])]
  124.     #[Assert\NotNull]
  125.     #[Assert\CssColor]
  126.     #[ORM\Column(typeTypes::STRINGlength255options: ['default' => '#5E9959'])]
  127.     private string $headerBgColor '#5E9959';
  128.     #[ApiProperty(description'Header text color')]
  129.     #[Groups(['read:' Journal::class, 'write'])]
  130.     #[Assert\NotNull]
  131.     #[Assert\CssColor]
  132.     #[ORM\Column(typeTypes::STRINGlength255options: ['default' => '#fff'])]
  133.     private string $headerTextColor '#fff';
  134.     #[ApiProperty(description'Header text font'writableLinkfalse)]
  135.     #[Groups(['read:' Journal::class, 'write'])]
  136.     #[ORM\Column(
  137.         typeTypes::STRING,
  138.         enumTypeFont::class,
  139.         length255,
  140.         options: ['default' => Font::ARIAL]
  141.     )]
  142.     private Font $headerTextFont Font::ARIAL;
  143.     #[ApiProperty(description'Menu background color')]
  144.     #[Groups(['read:' Journal::class, 'write'])]
  145.     #[Assert\NotNull]
  146.     #[Assert\CssColor]
  147.     #[ORM\Column(typeTypes::STRINGlength255options: ['default' => '#000'])]
  148.     private string $menuBgColor '#000';
  149.     #[ApiProperty(description'Menu text color')]
  150.     #[Groups(['read:' Journal::class, 'write'])]
  151.     #[Assert\NotNull]
  152.     #[Assert\CssColor]
  153.     #[ORM\Column(typeTypes::STRINGlength255options: ['default' => '#fff'])]
  154.     private string $menuTextColor '#fff';
  155.     #[ApiProperty(description'Menu text font'writableLinkfalse)]
  156.     #[Groups(['read:' Journal::class, 'write'])]
  157.     #[ORM\Column(
  158.         typeTypes::STRING,
  159.         enumTypeFont::class,
  160.         length255,
  161.         options: ['default' => Font::ARIAL]
  162.     )]
  163.     private Font $menuTextFont Font::ARIAL;
  164.     #[ApiProperty(description'Submenu background color')]
  165.     #[Groups(['read:' Journal::class, 'write'])]
  166.     #[Assert\CssColor]
  167.     #[ORM\Column(typeTypes::STRINGlength255options: ['default' => '#000'])]
  168.     private string $submenuBgColor '#000';
  169.     #[ApiProperty(description'Submenu text color')]
  170.     #[Groups(['read:' Journal::class, 'write'])]
  171.     #[Assert\CssColor]
  172.     #[ORM\Column(typeTypes::STRINGlength255options: ['default' => '#fff'])]
  173.     private string $submenuTextColor '#fff';
  174.     #[ApiProperty(description'Submenu text font'writableLinkfalse)]
  175.     #[Groups(['read:' Journal::class, 'write'])]
  176.     #[ORM\Column(
  177.         typeTypes::STRING,
  178.         enumTypeFont::class,
  179.         length255,
  180.         options: ['default' => Font::ARIAL]
  181.     )]
  182.     private Font $submenuTextFont Font::ARIAL;
  183.     #[ApiProperty(description'Color accent'writableLinkfalse)]
  184.     #[Groups(['read:' Journal::class, 'write'])]
  185.     #[ORM\Column(typeTypes::STRINGenumTypeJournalColorAccent::class, length255nullabletrue)]
  186.     private ?JournalColorAccent $colorAccent null;
  187.     #[ApiProperty(description'Visible editorial group member properties'writableLinkfalse)]
  188.     #[Groups(['read:' Journal::class, 'write'])]
  189.     #[Assert\Choice(callback: [AuthorProperty::class, 'cases'], multipletrue)]
  190.     #[Assert\Unique]
  191.     #[Assert\Count(min1)]
  192.     #[ORM\Column(typeAuthorPropertiesType::NAME)]
  193.     private array $visibleEditorialGroupMemberProperties = [
  194.         AuthorProperty::PREFIX,
  195.         AuthorProperty::NAME,
  196.         AuthorProperty::SURNAME,
  197.         AuthorProperty::AFFILIATION
  198.     ];
  199.     #[ApiProperty(description'Visible scientific council member properties'writableLinkfalse)]
  200.     #[Groups(['read:' Journal::class, 'write'])]
  201.     #[Assert\Choice(callback: [AuthorProperty::class, 'cases'], multipletrue)]
  202.     #[Assert\Unique]
  203.     #[Assert\Count(min1)]
  204.     #[ORM\Column(typeAuthorPropertiesType::NAME)]
  205.     private array $visibleScientificCouncilMemberProperties = [
  206.         AuthorProperty::PREFIX,
  207.         AuthorProperty::NAME,
  208.         AuthorProperty::SURNAME,
  209.         AuthorProperty::AFFILIATION
  210.     ];
  211.     #[ApiProperty(description'Is editorial groups visible in volumes and numbers')]
  212.     #[Groups(['read:' Journal::class, 'write'])]
  213.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => true])]
  214.     private bool $isEditorialGroupsVisibleInVolumesAndNumbers true;
  215.     #[ApiProperty(description'Is footer column A visible')]
  216.     #[Groups(['read:' Journal::class, 'write'])]
  217.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  218.     private bool $isFooterColumnAVisible false;
  219.     #[ApiProperty(description'Is footer column B visible')]
  220.     #[Groups(['read:' Journal::class, 'write'])]
  221.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  222.     private bool $isFooterColumnBVisible false;
  223.     #[ApiProperty(description'Is footer column C visible')]
  224.     #[Groups(['read:' Journal::class, 'write'])]
  225.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  226.     private bool $isFooterColumnCVisible false;
  227.     #[ApiProperty(description'Is footer column D visible')]
  228.     #[Groups(['read:' Journal::class, 'write'])]
  229.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  230.     private bool $isFooterColumnDVisible false;
  231.     public function __construct(Journal $parent)
  232.     {
  233.         $this->setUuid();
  234.         $this->parent $parent;
  235.     }
  236.     public function getParent(): Journal
  237.     {
  238.         return $this->parent;
  239.     }
  240.     public function getCoverType(): JournalCoverType
  241.     {
  242.         return $this->coverType;
  243.     }
  244.     public function setCoverType(JournalCoverType $coverType): self
  245.     {
  246.         $this->coverType $coverType;
  247.         return $this;
  248.     }
  249.     public function getTemplate(): JournalPageTemplate
  250.     {
  251.         return $this->template;
  252.     }
  253.     public function setTemplate(JournalPageTemplate $template): self
  254.     {
  255.         $this->template $template;
  256.         return $this;
  257.     }
  258.     public function getIsAffiliationVisibleInHeader(): bool
  259.     {
  260.         return $this->isAffiliationVisibleInHeader;
  261.     }
  262.     public function setIsAffiliationVisibleInHeader(bool $isAffiliationVisibleInHeader): self
  263.     {
  264.         $this->isAffiliationVisibleInHeader $isAffiliationVisibleInHeader;
  265.         return $this;
  266.     }
  267.     public function getAlertAIsVisible(): bool
  268.     {
  269.         return $this->alertAIsVisible;
  270.     }
  271.     public function setAlertAIsVisible(bool $alertAIsVisible): self
  272.     {
  273.         $this->alertAIsVisible $alertAIsVisible;
  274.         return $this;
  275.     }
  276.     public function getAlertAType(): AlertType
  277.     {
  278.         return $this->alertAType;
  279.     }
  280.     public function setAlertAType(AlertType $alertAType): self
  281.     {
  282.         $this->alertAType $alertAType;
  283.         return $this;
  284.     }
  285.     public function getAlertAIsTakeOffActive(): bool
  286.     {
  287.         return $this->alertAIsTakeOffActive;
  288.     }
  289.     public function setAlertAIsTakeOffActive(bool $alertAIsTakeOffActive): self
  290.     {
  291.         $this->alertAIsTakeOffActive $alertAIsTakeOffActive;
  292.         return $this;
  293.     }
  294.     public function getAlertATakeOffDateTime(): ?\DateTimeInterface
  295.     {
  296.         return $this->alertATakeOffDateTime;
  297.     }
  298.     public function setAlertATakeOffDateTime(?\DateTimeInterface $alertATakeOffDateTime): self
  299.     {
  300.         $this->alertATakeOffDateTime $alertATakeOffDateTime;
  301.         if (! $alertATakeOffDateTime) {
  302.             $this->alertAIsTakeOffActive false;
  303.         }
  304.         return $this;
  305.     }
  306.     public function getAlertBIsVisible(): bool
  307.     {
  308.         return $this->alertBIsVisible;
  309.     }
  310.     public function setAlertBIsVisible(bool $alertBIsVisible): self
  311.     {
  312.         $this->alertBIsVisible $alertBIsVisible;
  313.         return $this;
  314.     }
  315.     public function getAlertBType(): AlertType
  316.     {
  317.         return $this->alertBType;
  318.     }
  319.     public function setAlertBType(AlertType $alertBType): self
  320.     {
  321.         $this->alertBType $alertBType;
  322.         return $this;
  323.     }
  324.     public function getAlertBIsTakeOffActive(): bool
  325.     {
  326.         return $this->alertBIsTakeOffActive;
  327.     }
  328.     public function setAlertBIsTakeOffActive(bool $alertBIsTakeOffActive): self
  329.     {
  330.         $this->alertBIsTakeOffActive $alertBIsTakeOffActive;
  331.         return $this;
  332.     }
  333.     public function getAlertBTakeOffDateTime(): ?\DateTimeInterface
  334.     {
  335.         return $this->alertBTakeOffDateTime;
  336.     }
  337.     public function setAlertBTakeOffDateTime(?\DateTimeInterface $alertBTakeOffDateTime): self
  338.     {
  339.         $this->alertBTakeOffDateTime $alertBTakeOffDateTime;
  340.         if (! $alertBTakeOffDateTime) {
  341.             $this->alertBIsTakeOffActive false;
  342.         }
  343.         return $this;
  344.     }
  345.     private function clearAlert(string $type): self
  346.     {
  347.         $isTakeOffActive 'alert' strtoupper($type) . 'IsTakeOffActive';
  348.         $takeOffDateTime 'alert' strtoupper($type) . 'TakeOffDateTime';
  349.         if (
  350.             ! $this->$isTakeOffActive
  351.             || (new \DateTimeImmutable()) < $this->$takeOffDateTime
  352.         ) {
  353.             return $this;
  354.         }
  355.         $isVisible 'alert' strtoupper($type) . 'IsVisible';
  356.         $this->$isVisible false;
  357.         $this->$isTakeOffActive false;
  358.         $this->$takeOffDateTime null;
  359.         return $this;
  360.     }
  361.     public function clearAlerts(): self
  362.     {
  363.         $this
  364.             ->clearAlert('a')
  365.             ->clearAlert('b');
  366.         return $this;
  367.     }
  368.     public function getHasBadge(): bool
  369.     {
  370.         return $this->hasBadge;
  371.     }
  372.     public function setHasBadge(bool $hasBadge): self
  373.     {
  374.         $this->hasBadge $hasBadge;
  375.         return $this;
  376.     }
  377.     public function getAffiliationLogoType(): JournalAffiliationLogoType
  378.     {
  379.         return $this->affiliationLogoType;
  380.     }
  381.     public function setAffiliationLogoType(JournalAffiliationLogoType $affiliationLogoType): self
  382.     {
  383.         $this->affiliationLogoType $affiliationLogoType;
  384.         return $this;
  385.     }
  386.     public function getHeaderBgColor(): string
  387.     {
  388.         return $this->headerBgColor;
  389.     }
  390.     public function setHeaderBgColor(string $headerBgColor): self
  391.     {
  392.         $this->headerBgColor $headerBgColor;
  393.         return $this;
  394.     }
  395.     public function getHeaderTextColor(): string
  396.     {
  397.         return $this->headerTextColor;
  398.     }
  399.     public function setHeaderTextColor(string $headerTextColor): self
  400.     {
  401.         $this->headerTextColor $headerTextColor;
  402.         return $this;
  403.     }
  404.     public function getHeaderTextFont(): Font
  405.     {
  406.         return $this->headerTextFont;
  407.     }
  408.     public function setHeaderTextFont(Font $headerTextFont): self
  409.     {
  410.         $this->headerTextFont $headerTextFont;
  411.         return $this;
  412.     }
  413.     public function getMenuBgColor(): string
  414.     {
  415.         return $this->menuBgColor;
  416.     }
  417.     public function setMenuBgColor(string $menuBgColor): self
  418.     {
  419.         $this->menuBgColor $menuBgColor;
  420.         return $this;
  421.     }
  422.     public function getMenuTextColor(): string
  423.     {
  424.         return $this->menuTextColor;
  425.     }
  426.     public function setMenuTextColor(string $menuTextColor): self
  427.     {
  428.         $this->menuTextColor $menuTextColor;
  429.         return $this;
  430.     }
  431.     public function getMenuTextFont(): Font
  432.     {
  433.         return $this->menuTextFont;
  434.     }
  435.     public function setMenuTextFont(Font $menuTextFont): self
  436.     {
  437.         $this->menuTextFont $menuTextFont;
  438.         return $this;
  439.     }
  440.     public function getSubmenuBgColor(): string
  441.     {
  442.         return $this->submenuBgColor;
  443.     }
  444.     public function setSubmenuBgColor(string $submenuBgColor): self
  445.     {
  446.         $this->submenuBgColor $submenuBgColor;
  447.         return $this;
  448.     }
  449.     public function getSubmenuTextColor(): string
  450.     {
  451.         return $this->submenuTextColor;
  452.     }
  453.     public function setSubmenuTextColor(string $submenuTextColor): self
  454.     {
  455.         $this->submenuTextColor $submenuTextColor;
  456.         return $this;
  457.     }
  458.     public function getSubmenuTextFont(): Font
  459.     {
  460.         return $this->submenuTextFont;
  461.     }
  462.     public function setSubmenuTextFont(Font $submenuTextFont): self
  463.     {
  464.         $this->submenuTextFont $submenuTextFont;
  465.         return $this;
  466.     }
  467.     public function getColorAccent(): ?JournalColorAccent
  468.     {
  469.         return $this->colorAccent;
  470.     }
  471.     public function setColorAccent(?JournalColorAccent $colorAccent): self
  472.     {
  473.         $this->colorAccent $colorAccent;
  474.         return $this;
  475.     }
  476.     public function getVisibleEditorialGroupMemberProperties(): array
  477.     {
  478.         return $this->visibleEditorialGroupMemberProperties;
  479.     }
  480.     public function setVisibleEditorialGroupMemberProperties(array $visibleEditorialGroupMemberProperties): self
  481.     {
  482.         $this->visibleEditorialGroupMemberProperties $visibleEditorialGroupMemberProperties;
  483.         return $this;
  484.     }
  485.     public function getVisibleScientificCouncilMemberProperties(): array
  486.     {
  487.         return $this->visibleScientificCouncilMemberProperties;
  488.     }
  489.     public function setVisibleScientificCouncilMemberProperties(array $visibleScientificCouncilMemberProperties): self
  490.     {
  491.         $this->visibleScientificCouncilMemberProperties $visibleScientificCouncilMemberProperties;
  492.         return $this;
  493.     }
  494.     public function getIsEditorialGroupsVisibleInVolumesAndNumbers(): bool
  495.     {
  496.         return $this->isEditorialGroupsVisibleInVolumesAndNumbers;
  497.     }
  498.     public function setIsEditorialGroupsVisibleInVolumesAndNumbers(bool $isEditorialGroupsVisibleInVolumesAndNumbers): self
  499.     {
  500.         $this->isEditorialGroupsVisibleInVolumesAndNumbers $isEditorialGroupsVisibleInVolumesAndNumbers;
  501.         return $this;
  502.     }
  503.     public function getIsFooterColumnAVisible(): bool
  504.     {
  505.         return $this->isFooterColumnAVisible;
  506.     }
  507.     public function setIsFooterColumnAVisible(bool $isFooterColumnAVisible): self
  508.     {
  509.         $this->isFooterColumnAVisible $isFooterColumnAVisible;
  510.         return $this;
  511.     }
  512.     public function getIsFooterColumnBVisible(): bool
  513.     {
  514.         return $this->isFooterColumnBVisible;
  515.     }
  516.     public function setIsFooterColumnBVisible(bool $isFooterColumnBVisible): self
  517.     {
  518.         $this->isFooterColumnBVisible $isFooterColumnBVisible;
  519.         return $this;
  520.     }
  521.     public function getIsFooterColumnCVisible(): bool
  522.     {
  523.         return $this->isFooterColumnCVisible;
  524.     }
  525.     public function setIsFooterColumnCVisible(bool $isFooterColumnCVisible): self
  526.     {
  527.         $this->isFooterColumnCVisible $isFooterColumnCVisible;
  528.         return $this;
  529.     }
  530.     public function getIsFooterColumnDVisible(): bool
  531.     {
  532.         return $this->isFooterColumnDVisible;
  533.     }
  534.     public function setIsFooterColumnDVisible(bool $isFooterColumnDVisible): self
  535.     {
  536.         $this->isFooterColumnDVisible $isFooterColumnDVisible;
  537.         return $this;
  538.     }
  539.     public function clone(Journal $parent): self
  540.     {
  541.         $clone = clone $this;
  542.         $clone->id null;
  543.         $clone->setUuid();
  544.         $clone->alertATakeOffDateTime null;
  545.         $clone->alertAIsTakeOffActive false;
  546.         $clone->alertBTakeOffDateTime null;
  547.         $clone->alertBIsTakeOffActive false;
  548.         $clone->parent $parent;
  549.         return $clone;
  550.     }
  551. }