src/Pumukit/SchemaBundle/Document/Series.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Pumukit\SchemaBundle\Document;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
  6. use JMS\Serializer\Annotation as Serializer;
  7. /**
  8.  * @MongoDB\Document(repositoryClass="Pumukit\SchemaBundle\Repository\SeriesRepository")
  9.  *
  10.  * @MongoDB\Index(name="text_index", keys={"textindex.text"="text", "secondarytextindex.text"="text"}, options={"language_override"="indexlanguage", "default_language"="none", "weights"={"textindex.text"=10, "secondarytextindex.text"=1}})
  11.  *
  12.  * @ApiResource(
  13.  *       collectionOperations={"get"={"method"="GET", "access_control"="is_granted('ROLE_ACCESS_API')"}},
  14.  *       itemOperations={"get"={"method"="GET", "access_control"="is_granted('ROLE_ACCESS_API')"}}
  15.  *   )
  16.  */
  17. class Series
  18. {
  19.     use Traits\Keywords;
  20.     use Traits\Properties;
  21.     use Traits\HeadAndTail;
  22.     use Traits\Pic {
  23.         Traits\Pic::__construct as private __PicConstruct;
  24.     }
  25.     public const TYPE_SERIES 0;
  26.     public const TYPE_PLAYLIST 1;
  27.     public const SORT_MANUAL 0;
  28.     public const SORT_PUB_ASC 1;
  29.     public const SORT_PUB_DES 2;
  30.     public const SORT_REC_DES 3;
  31.     public const SORT_REC_ASC 4;
  32.     public const SORT_ALPHAB 5;
  33.     public static $sortCriteria = [
  34.         self::SORT_MANUAL => ['rank' => 'asc'],
  35.         self::SORT_PUB_ASC => ['public_date' => 'asc'],
  36.         self::SORT_PUB_DES => ['public_date' => 'des'],
  37.         self::SORT_REC_DES => ['record_date' => 'des'],
  38.         self::SORT_REC_ASC => ['record_date' => 'asc'],
  39.         self::SORT_ALPHAB => ['title.es' => 'asc'],
  40.     ];
  41.     public static $sortText = [
  42.         self::SORT_MANUAL => 'manual',
  43.         self::SORT_PUB_ASC => 'publication date ascending',
  44.         self::SORT_PUB_DES => 'publication date descending',
  45.         self::SORT_REC_DES => 'recording date descending',
  46.         self::SORT_REC_ASC => 'recording date ascending',
  47.         self::SORT_ALPHAB => 'title',
  48.     ];
  49.     /**
  50.      * @MongoDB\Id
  51.      */
  52.     protected $id;
  53.     /**
  54.      * @MongoDB\Field(type="int")
  55.      *
  56.      * @MongoDB\UniqueIndex()
  57.      */
  58.     private $numerical_id;
  59.     /**
  60.      * @MongoDB\Field(type="string")
  61.      *
  62.      * @MongoDB\Index
  63.      */
  64.     private $secret;
  65.     /**
  66.      * @MongoDB\Field(type="int")
  67.      *
  68.      * @MongoDB\Index
  69.      */
  70.     private $type;
  71.     /**
  72.      * @MongoDB\Field(type="int")
  73.      */
  74.     private $sorting self::SORT_MANUAL;
  75.     /**
  76.      * @MongoDB\ReferenceOne(targetDocument=SeriesType::class, inversedBy="series", storeAs="id", cascade={"persist"})
  77.      */
  78.     private $series_type;
  79.     /**
  80.      * @MongoDB\ReferenceOne(targetDocument=SeriesStyle::class, inversedBy="series", storeAs="id", cascade={"persist"})
  81.      */
  82.     private $series_style;
  83.     /**
  84.      * @MongoDB\EmbedOne(targetDocument=Playlist::class)
  85.      *
  86.      * @Serializer\Exclude
  87.      */
  88.     private $playlist;
  89.     /**
  90.      * @MongoDB\Field(type="bool")
  91.      */
  92.     private $announce false;
  93.     /**
  94.      * When series is hide and we access to the series with the mmobj->getSeries(),
  95.      * it creates a pseudo series with default values (the WebTV filter dont permit to access hide series),
  96.      * and we want to force that the series will be hide.
  97.      *
  98.      * @MongoDB\Field(type="bool")
  99.      *
  100.      * @MongoDB\Index
  101.      */
  102.     private $hide false;
  103.     /**
  104.      * @MongoDB\Field(type="date")
  105.      *
  106.      * @MongoDB\Index
  107.      */
  108.     private $public_date;
  109.     /**
  110.      * @MongoDB\Field(type="raw")
  111.      */
  112.     private $title = ['en' => ''];
  113.     /**
  114.      * @MongoDB\Field(type="raw")
  115.      */
  116.     private $subtitle = ['en' => ''];
  117.     /**
  118.      * @MongoDB\Field(type="raw")
  119.      */
  120.     private $description = ['en' => ''];
  121.     /**
  122.      * @MongoDB\Field(type="string")
  123.      */
  124.     private $comments;
  125.     /**
  126.      * @MongoDB\Field(type="raw")
  127.      */
  128.     private $header = ['en' => ''];
  129.     /**
  130.      * @MongoDB\Field(type="raw")
  131.      */
  132.     private $footer = ['en' => ''];
  133.     /**
  134.      * @MongoDB\Field(type="raw")
  135.      */
  136.     private $line2 = ['en' => ''];
  137.     /**
  138.      * @MongoDB\Field(type="raw")
  139.      */
  140.     private $textindex = [];
  141.     /**
  142.      * @MongoDB\Field(type="raw")
  143.      */
  144.     private $secondarytextindex = [];
  145.     /**
  146.      * Used locale to override Translation listener`s locale this is not a mapped field of entity metadata, just a simple property.
  147.      */
  148.     private $locale 'en';
  149.     public function __construct()
  150.     {
  151.         $this->secret base_convert(sha1(uniqid((string) random_int(0mt_getrandmax()), true)), 1636);
  152.         $this->playlist = new Playlist();
  153.         $this->__PicConstruct();
  154.     }
  155.     public function __toString(): string
  156.     {
  157.         return $this->getTitle();
  158.     }
  159.     public function isCollection(): bool
  160.     {
  161.         return true;
  162.     }
  163.     public function getId()
  164.     {
  165.         return $this->id;
  166.     }
  167.     public function getNumericalID()
  168.     {
  169.         return $this->numerical_id;
  170.     }
  171.     public function setNumericalID($numericalID)
  172.     {
  173.         return $this->numerical_id $numericalID;
  174.     }
  175.     public function getSecret(): string
  176.     {
  177.         return $this->secret;
  178.     }
  179.     public function resetSecret(): string
  180.     {
  181.         $this->secret base_convert(sha1(uniqid((string) random_int(0mt_getrandmax()), true)), 1636);
  182.         return $this->secret;
  183.     }
  184.     public function getType()
  185.     {
  186.         return $this->type;
  187.     }
  188.     public function setType($type)
  189.     {
  190.         return $this->type $type;
  191.     }
  192.     public function isPlaylist(): bool
  193.     {
  194.         return self::TYPE_PLAYLIST === $this->type;
  195.     }
  196.     public function getSorting(): int
  197.     {
  198.         return $this->sorting;
  199.     }
  200.     public function getSortingCriteria(): array
  201.     {
  202.         return self::$sortCriteria[$this->sorting] ?? self::$sortCriteria[0];
  203.     }
  204.     public function setSorting($sorting)
  205.     {
  206.         return $this->sorting $sorting;
  207.     }
  208.     public function setSeriesType(SeriesType $series_type): void
  209.     {
  210.         $this->series_type $series_type;
  211.     }
  212.     public function getSeriesType()
  213.     {
  214.         return $this->series_type;
  215.     }
  216.     public function setSeriesStyle(SeriesStyle $series_style null): void
  217.     {
  218.         $this->series_style $series_style;
  219.     }
  220.     public function getSeriesStyle()
  221.     {
  222.         return $this->series_style;
  223.     }
  224.     public function setPlaylist(Playlist $playlist): void
  225.     {
  226.         $this->playlist $playlist;
  227.     }
  228.     public function getPlaylist(): Playlist
  229.     {
  230.         return $this->playlist;
  231.     }
  232.     public function setAnnounce($announce): void
  233.     {
  234.         $this->announce $announce;
  235.     }
  236.     public function getAnnounce(): bool
  237.     {
  238.         return $this->announce;
  239.     }
  240.     public function isAnnounce(): bool
  241.     {
  242.         return $this->announce;
  243.     }
  244.     public function setHide($hide): void
  245.     {
  246.         $this->hide $hide;
  247.     }
  248.     public function getHide(): bool
  249.     {
  250.         return $this->hide;
  251.     }
  252.     public function isHide(): bool
  253.     {
  254.         return true === $this->hide;
  255.     }
  256.     public function setPublicDate($public_date): void
  257.     {
  258.         $this->public_date $public_date;
  259.     }
  260.     public function getPublicDate()
  261.     {
  262.         return $this->public_date;
  263.     }
  264.     public function setTitle($title$locale null): void
  265.     {
  266.         if (null === $locale) {
  267.             $locale $this->locale;
  268.         }
  269.         $this->title[$locale] = $title;
  270.     }
  271.     public function getTitle($locale null): string
  272.     {
  273.         if (null === $locale) {
  274.             $locale $this->locale;
  275.         }
  276.         return $this->title[$locale] ?? '';
  277.     }
  278.     public function setI18nTitle(array $title): void
  279.     {
  280.         $this->title $title;
  281.     }
  282.     public function getI18nTitle(): array
  283.     {
  284.         return $this->title;
  285.     }
  286.     public function setSubtitle($subtitle$locale null): void
  287.     {
  288.         if (null === $locale) {
  289.             $locale $this->locale;
  290.         }
  291.         $this->subtitle[$locale] = $subtitle;
  292.     }
  293.     public function getSubtitle($locale null): string
  294.     {
  295.         if (null === $locale) {
  296.             $locale $this->locale;
  297.         }
  298.         return $this->subtitle[$locale] ?? '';
  299.     }
  300.     public function setI18nSubtitle(array $subtitle): void
  301.     {
  302.         $this->subtitle $subtitle;
  303.     }
  304.     public function getI18nSubtitle(): array
  305.     {
  306.         return $this->subtitle;
  307.     }
  308.     public function setDescription($description$locale null): void
  309.     {
  310.         if (null === $locale) {
  311.             $locale $this->locale;
  312.         }
  313.         $this->description[$locale] = $description;
  314.     }
  315.     public function getDescription($locale null): string
  316.     {
  317.         if (null === $locale) {
  318.             $locale $this->locale;
  319.         }
  320.         return $this->description[$locale] ?? '';
  321.     }
  322.     public function setComments($comments): void
  323.     {
  324.         $this->comments $comments;
  325.     }
  326.     public function getComments()
  327.     {
  328.         return $this->comments;
  329.     }
  330.     public function setI18nDescription(array $description): void
  331.     {
  332.         $this->description $description;
  333.     }
  334.     public function getI18nDescription(): array
  335.     {
  336.         return $this->description;
  337.     }
  338.     public function setHeader($header$locale null): void
  339.     {
  340.         if (null === $locale) {
  341.             $locale $this->locale;
  342.         }
  343.         $this->header[$locale] = $header;
  344.     }
  345.     public function getHeader($locale null): string
  346.     {
  347.         if (null === $locale) {
  348.             $locale $this->locale;
  349.         }
  350.         return $this->header[$locale] ?? '';
  351.     }
  352.     public function setI18nHeader(array $header): void
  353.     {
  354.         $this->header $header;
  355.     }
  356.     public function getI18nHeader(): array
  357.     {
  358.         return $this->header;
  359.     }
  360.     public function setFooter($footer$locale null): void
  361.     {
  362.         if (null === $locale) {
  363.             $locale $this->locale;
  364.         }
  365.         $this->footer[$locale] = $footer;
  366.     }
  367.     public function getFooter($locale null): string
  368.     {
  369.         if (null === $locale) {
  370.             $locale $this->locale;
  371.         }
  372.         return $this->footer[$locale] ?? '';
  373.     }
  374.     public function setI18nFooter(array $footer): void
  375.     {
  376.         $this->footer $footer;
  377.     }
  378.     public function getI18nFooter(): array
  379.     {
  380.         return $this->footer;
  381.     }
  382.     public function setCopyright($copyright): void
  383.     {
  384.         $this->setProperty('copyright'$copyright);
  385.     }
  386.     /**
  387.      * @deprecated Dont use this method, use getProperty('copyright')
  388.      */
  389.     public function getCopyright()
  390.     {
  391.         return $this->getProperty('copyright');
  392.     }
  393.     /**
  394.      * @deprecated  Dont use this method, use setProperty('license', $license)
  395.      *
  396.      * @param mixed $license
  397.      */
  398.     public function setLicense($license): void
  399.     {
  400.         $this->setProperty('license'$license);
  401.     }
  402.     /**
  403.      * @deprecated Dont use this method, use getProperty('license')
  404.      */
  405.     public function getLicense()
  406.     {
  407.         return $this->getProperty('license');
  408.     }
  409.     public function setLine2($line2$locale null): void
  410.     {
  411.         if (null === $locale) {
  412.             $locale $this->locale;
  413.         }
  414.         $this->line2[$locale] = $line2;
  415.     }
  416.     public function getLine2($locale null): string
  417.     {
  418.         if (null === $locale) {
  419.             $locale $this->locale;
  420.         }
  421.         return $this->line2[$locale] ?? '';
  422.     }
  423.     public function setI18nLine2(array $line2): void
  424.     {
  425.         $this->line2 $line2;
  426.     }
  427.     public function getI18nLine2(): array
  428.     {
  429.         return $this->line2;
  430.     }
  431.     public function setLocale($locale): void
  432.     {
  433.         $this->locale $locale;
  434.     }
  435.     public function getLocale(): string
  436.     {
  437.         return $this->locale;
  438.     }
  439.     public function setTextIndex($textindex): void
  440.     {
  441.         $this->textindex $textindex;
  442.     }
  443.     public function getTextIndex(): array
  444.     {
  445.         return $this->textindex;
  446.     }
  447.     public function setSecondaryTextIndex($secondarytextindex): void
  448.     {
  449.         $this->secondarytextindex $secondarytextindex;
  450.     }
  451.     public function getSecondaryTextIndex(): array
  452.     {
  453.         return $this->secondarytextindex;
  454.     }
  455. }