src/Entity/Article.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Traits\CreatedUpdatedTrait;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use JMS\Serializer\Annotation\Expose;
  7. use JMS\Serializer\Annotation\Exclude;
  8. use JMS\Serializer\Annotation\ExclusionPolicy;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use JMS\Serializer\Annotation\VirtualProperty;
  11. /**
  12.  * @ORM\Table(name="v_article")
  13.  * @ORM\Entity(repositoryClass="App\Repository\ArticleRepository")
  14.  * @ORM\HasLifecycleCallbacks()
  15.  *  @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=true)
  16.  */
  17. class Article
  18. {
  19.     const ARTICLE_LINK_TYPE_AUDIO 'AUDIO';
  20.     const ARTICLE_LINK_TYPE_VIDEO 'VIDEO';
  21.     const ARTICLE_LINK_TYPE_GLOBAL 'GLOBAL';
  22.     const ARTICLE_TYPE_IN_APP 'IN_APP';
  23.     const ARTICLE_TYPE_EXTERNAL 'EXTERNAL';
  24.     public static function getArticleLinkTypeDefinitions(){
  25.         return [
  26.             self::ARTICLE_LINK_TYPE_AUDIO => 'Audio',
  27.             self::ARTICLE_LINK_TYPE_VIDEO => 'Video',
  28.             self::ARTICLE_LINK_TYPE_GLOBAL => 'Global',
  29.         ];
  30.     }
  31.     public static function getArticleTypeDefinitions(){
  32.         return [
  33.             self::ARTICLE_TYPE_IN_APP => 'In App',
  34.             self::ARTICLE_TYPE_EXTERNAL => 'External',
  35.         ];
  36.     }
  37.     /**
  38.      * @ORM\Id()
  39.      * @ORM\GeneratedValue()
  40.      * @ORM\Column(type="integer")
  41.      */
  42.     private $id;
  43.     /**
  44.      * @ORM\Column(type="string", length=55)
  45.      */
  46.     private $title;
  47.     /**
  48.      * @var string
  49.      * @Gedmo\Slug(fields={"title"}, updatable=false)
  50.      * @ORM\Column(type="string", length=255)
  51.      */
  52.     private $slug;
  53.     /**
  54.      * @ORM\Column(type="string", length=255, nullable=true)
  55.      */
  56.     private $image;
  57.     /**
  58.      * @ORM\Column(name="detail_image", type="string", length=255, nullable=true)
  59.      */
  60.     private $detailImage;
  61.     /**
  62.      * 
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      */
  65.     private $caption;
  66.     /**
  67.      * @ORM\Column(type="text", nullable=true)
  68.      */
  69.     private $content;
  70.     /**
  71.      * @ORM\Column(type="boolean")
  72.      */
  73.     private $enabled true ;
  74.     /**
  75.      * @ORM\ManyToOne(targetEntity="App\Entity\ArticleCategory", inversedBy="articles")
  76.      * @Exclude
  77.      */
  78.     private $category;
  79.     /**
  80.      * @ORM\Column(type="string", length=255, nullable=true)
  81.      */
  82.     private $link;
  83.     /**
  84.      * @ORM\Column(type="string", length=255, nullable=true)
  85.      */
  86.     private $linkType;
  87.     /**
  88.      * @var string
  89.      *
  90.      * @ORM\Column(name="button_text", type="string", length=28, nullable=true)
  91.      */
  92.     private $buttonText;
  93.      /**
  94.      * @var string
  95.      *
  96.      * @ORM\Column(name="tracking_code", type="string", length=255, nullable=true)
  97.      */
  98.     private $trackingCode;
  99.     /**
  100.      * 
  101.      * @ORM\Column(type="string", length=255, nullable=true)
  102.      */
  103.     private $articleType;
  104.     /**
  105.      * @Gedmo\SortablePosition
  106.      * @ORM\Column(type="integer")
  107.      */
  108.     private $position=0;
  109.     /**
  110.      * @ORM\Column(type="text", nullable=true)
  111.      */
  112.     private $previewText;
  113.     /**
  114.      * @ORM\Column(type="text", nullable=true)
  115.      */
  116.     private $freeText;
  117.     /**
  118.      * @ORM\Column(name="deleted_at", type="datetime", nullable=true)
  119.      */
  120.     private $deletedAt;
  121.     /**
  122.      * @ORM\Column(name="read_time", type="integer", nullable=true)
  123.      */
  124.     private $readTime;
  125.     /**
  126.      * @ORM\Column(type="string", length=20, nullable=true)
  127.      */
  128.     private $language;
  129.     public function __construct()
  130.     {
  131.         $this->setTrackingCode('iom-article-'.date('Ymdhis').'-'.rand(1000,9999));
  132.     }
  133.     use CreatedUpdatedTrait;
  134.     public function __toString()
  135.     {
  136.         return (string) $this->title;
  137.     }
  138.     public function getId(): ?int
  139.     {
  140.         return $this->id;
  141.     }
  142.     public function getTitle(): ?string
  143.     {
  144.         return $this->title;
  145.     }
  146.     public function setTitle(string $title): self
  147.     {
  148.         $this->title $title;
  149.         return $this;
  150.     }
  151.     /**
  152.      * @return string|null
  153.      */
  154.     public function getSlug(): ?string
  155.     {
  156.         return $this->slug;
  157.     }
  158.     /**
  159.      * @param string|null $slug
  160.      * @return Article
  161.      */
  162.     public function setSlug(?string $slug): self
  163.     {
  164.         $this->slug $slug;
  165.         return $this;
  166.     }
  167.     public function getImage(): ?string
  168.     {
  169.         return $this->image;
  170.     }
  171.     public function setImage(?string $image): self
  172.     {
  173.         $this->image $image;
  174.         return $this;
  175.     }
  176.     /**
  177.      * @return mixed
  178.      */
  179.     public function getDetailImage()
  180.     {
  181.         return $this->detailImage;
  182.     }
  183.     /**
  184.      * @param mixed $detailImage
  185.      */
  186.     public function setDetailImage($detailImage): void
  187.     {
  188.         $this->detailImage $detailImage;
  189.     }
  190.     public function getCaption(): ?string
  191.     {
  192.         return $this->caption;
  193.     }
  194.     public function setCaption(?string $caption): self
  195.     {
  196.         $this->caption $caption;
  197.         return $this;
  198.     }
  199.     public function getContent(): ?string
  200.     {
  201.         return $this->content;
  202.     }
  203.     public function setContent(?string $content): self
  204.     {
  205.         $this->content $content;
  206.         return $this;
  207.     }
  208.     public function getEnabled(): ?bool
  209.     {
  210.         return $this->enabled;
  211.     }
  212.     public function setEnabled(bool $enabled): self
  213.     {
  214.         $this->enabled $enabled;
  215.         return $this;
  216.     }
  217.     /**
  218.      * @param mixed
  219.      */
  220.     public function getCategory(): ?ArticleCategory
  221.     {
  222.         return $this->category;
  223.     }
  224.     /**
  225.      * @param mixed $category
  226.      */
  227.     public function setCategory(?ArticleCategory $category): self
  228.     {
  229.         $this->category $category;
  230.         return $this;
  231.     }
  232.     public function getLink(): ?string
  233.     {
  234.         return $this->link;
  235.     }
  236.     public function setLink(?string $link): self
  237.     {
  238.         $this->link $link;
  239.         return $this;
  240.     }
  241.     public function getLinkType(): ?string
  242.     {
  243.         return $this->linkType;
  244.     }
  245.     public function setLinkType(?string $linkType): self
  246.     {
  247.         $this->linkType $linkType;
  248.         return $this;
  249.     }
  250.      /**
  251.      * @return string
  252.      */
  253.     public function getButtonText()
  254.     {
  255.         return $this->buttonText;
  256.     }
  257.     /**
  258.      * @param string $buttonText
  259.      */
  260.     public function setButtonText($buttonText)
  261.     {
  262.         $this->buttonText $buttonText;
  263.     }
  264.     /**
  265.      * @return string
  266.      */
  267.     public function getTrackingCode()
  268.     {
  269.         return $this->trackingCode;
  270.     }
  271.     /**
  272.      * @param string $trackingCode
  273.      */
  274.     public function setTrackingCode(?string $trackingCode)
  275.     {
  276.         $this->trackingCode $trackingCode;
  277.     }
  278.     public function getArticleType(): ?string
  279.     {
  280.         return $this->articleType;
  281.     }
  282.     public function setArticleType(?string $articleType): self
  283.     {
  284.         $this->articleType $articleType;
  285.         return $this;
  286.     }
  287.      /**
  288.      * @return mixed
  289.      */
  290.     public function getPosition()
  291.     {
  292.         return $this->position;
  293.     }
  294.     /**
  295.      * @param mixed $position
  296.      */
  297.     public function setPosition($position): void
  298.     {
  299.         $this->position $position;
  300.     }
  301.     public function getPreviewText(): ?string
  302.     {
  303.         return $this->previewText;
  304.     }
  305.     public function setPreviewText(?string $previewText): self
  306.     {
  307.         $this->previewText $previewText;
  308.         return $this;
  309.     }
  310.     /**
  311.      * @return mixed
  312.      */
  313.     public function getFreeText()
  314.     {
  315.         return $this->freeText;
  316.     }
  317.     /**
  318.      * @param mixed $freeText
  319.      */
  320.     public function setFreeText($freeText): void
  321.     {
  322.         $this->freeText $freeText;
  323.     }
  324.     /**
  325.      * @return mixed
  326.      */
  327.     public function getDeletedAt()
  328.     {
  329.         return $this->deletedAt;
  330.     }
  331.     /**
  332.      * @param mixed $deletedAt
  333.      */
  334.     public function setDeletedAt($deletedAt): void
  335.     {
  336.         $this->deletedAt $deletedAt;
  337.         $this->updated $deletedAt;
  338.     }
  339.     /**
  340.      * @return mixed
  341.      */
  342.     public function getReadTime()
  343.     {
  344.         return $this->readTime;
  345.     }
  346.     /**
  347.      * @param mixed $readTime
  348.      */
  349.     public function setReadTime($readTime): void
  350.     {
  351.         $this->readTime $readTime;
  352.     }
  353.     /**
  354.      * @return mixed
  355.      */
  356.     public function getLanguage()
  357.     {
  358.         return $this->language;
  359.     }
  360.     /**
  361.      * @param mixed $language
  362.      */
  363.     public function setLanguage($language): void
  364.     {
  365.         $this->language $language;
  366.     }
  367. }