src/Products/SocialBundle/Entity/SocialPost.php line 22

Open in your IDE?
  1. <?php
  2. namespace Products\SocialBundle\Entity;
  3. use App\Model\Async\StringSemaphoreInterface;
  4. use App\Model\Async\StringSemaphoreTrait;
  5. use Cms\TenantBundle\Entity\TenantedEntity;
  6. use DateTime;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * Class SocialPost
  10.  * @package Products\SocialBundle\Entity
  11.  *
  12.  * @ORM\Entity(
  13.  *     repositoryClass = "Products\SocialBundle\Doctrine\Repository\SocialPostRepository"
  14.  * )
  15.  * @ORM\Table(
  16.  *     name = "smm__post"
  17.  * )
  18.  */
  19. class SocialPost extends TenantedEntity implements StringSemaphoreInterface
  20. {
  21.     const STATUSES__SCHEDULED 0;
  22.     const STATUSES__POSTED 1;
  23.     const STATUSES__ERROR = -1;
  24.     use StringSemaphoreTrait;
  25.     /**
  26.      * @var SocialAccount
  27.      *
  28.      * @ORM\ManyToOne(
  29.      *     targetEntity = "SocialAccount"
  30.      * )
  31.      * @ORM\JoinColumn(
  32.      *     name = "socialAccount",
  33.      *     referencedColumnName = "id",
  34.      *     onDelete = "SET NULL"
  35.      * )
  36.      */
  37.     protected $socialAccount;
  38.     /**
  39.      * @var string
  40.      *
  41.      * @ORM\Column(
  42.      *     type = "text",
  43.      *     nullable = false
  44.      * )
  45.      */
  46.     protected $message;
  47.     /**
  48.      * @var string
  49.      *
  50.      * @ORM\Column(
  51.      *     type = "text",
  52.      *     nullable = true
  53.      * )
  54.      */
  55.     protected $link;
  56.     /**
  57.      * @var array|string[]
  58.      *
  59.      * @ORM\Column(
  60.      *     type = "json",
  61.      *     nullable = true
  62.      * )
  63.      */
  64.     protected $media = [];
  65.     /**
  66.      * @var DateTime
  67.      *
  68.      * @ORM\Column(
  69.      *     type = "datetime",
  70.      *     nullable = false
  71.      * )
  72.      */
  73.     protected $postAt;
  74.     /**
  75.      * @var DateTime
  76.      *
  77.      * @ORM\Column(
  78.      *     type = "datetime",
  79.      *     nullable = true
  80.      * )
  81.      */
  82.     protected $postedAt;
  83.     /**
  84.      * @var int
  85.      *
  86.      * @ORM\Column(
  87.      *     type = "string",
  88.      *     nullable = true
  89.      * )
  90.      */
  91.     protected $postedId;
  92.     /**
  93.      * @var string
  94.      *
  95.      * @ORM\Column(
  96.      *     type = "text",
  97.      *     nullable = true
  98.      * )
  99.      */
  100.     protected $postedDetails;
  101.     /**
  102.      * @var int
  103.      *
  104.      * @ORM\Column(
  105.      *     type = "integer",
  106.      *     nullable = false,
  107.      *     options = {
  108.      *         "default" = SocialPost::STATUSES__SCHEDULED
  109.      *     }
  110.      * )
  111.      */
  112.     protected $status self::STATUSES__SCHEDULED;
  113.     /**
  114.      * @var string
  115.      *
  116.      * @ORM\Column(
  117.      *     type = "text",
  118.      *     nullable = true
  119.      * )
  120.      */
  121.     protected $errorTrace;
  122.     /**
  123.      * @return bool
  124.      */
  125.     public function isPosted()
  126.     {
  127.         if ( ! empty($this->getPostedId())) {
  128.             return true;
  129.         }
  130.         return ($this->getStatus() !== self::STATUSES__SCHEDULED);
  131.     }
  132.     /**
  133.      * @return SocialAccount
  134.      */
  135.     public function getSocialAccount()
  136.     {
  137.         return $this->socialAccount;
  138.     }
  139.     /**
  140.      * @param SocialAccount $value
  141.      * @return $this
  142.      */
  143.     public function setSocialAccount(SocialAccount $value)
  144.     {
  145.         $this->socialAccount $value;
  146.         return $this;
  147.     }
  148.     /**
  149.      * @return string
  150.      */
  151.     public function getMessage()
  152.     {
  153.         return $this->message;
  154.     }
  155.     /**
  156.      * @param string $value
  157.      * @return $this
  158.      */
  159.     public function setMessage($value)
  160.     {
  161.         $this->message $value;
  162.         return $this;
  163.     }
  164.     /**
  165.      * @return string
  166.      */
  167.     public function getLink()
  168.     {
  169.         return $this->link;
  170.     }
  171.     /**
  172.      * @param string $value
  173.      * @return $this
  174.      */
  175.     public function setLink($value)
  176.     {
  177.         $this->link $value;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return array|string[]
  182.      */
  183.     public function getMedia()
  184.     {
  185.         return array_values(array_unique(array_filter($this->media)));
  186.     }
  187.     /**
  188.      * @param array|string[] $value
  189.      * @return $this
  190.      */
  191.     public function setMedia(array $value)
  192.     {
  193.         $this->media array_values(array_unique(array_filter($value)));
  194.         return $this;
  195.     }
  196.     /**
  197.      * @return DateTime
  198.      */
  199.     public function getPostAt()
  200.     {
  201.         return $this->postAt;
  202.     }
  203.     /**
  204.      * @param DateTime $value
  205.      * @return $this
  206.      */
  207.     public function setPostAt(DateTime $value null)
  208.     {
  209.         $this->postAt $value;
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return DateTime
  214.      */
  215.     public function getPostedAt()
  216.     {
  217.         return $this->postedAt;
  218.     }
  219.     /**
  220.      * @param DateTime $value
  221.      * @return $this
  222.      */
  223.     public function setPostedAt(DateTime $value null)
  224.     {
  225.         $this->postedAt $value;
  226.         return $this;
  227.     }
  228.     /**
  229.      * @return string
  230.      */
  231.     public function getPostedId()
  232.     {
  233.         return $this->postedId;
  234.     }
  235.     /**
  236.      * @param string $value
  237.      * @return $this
  238.      */
  239.     public function setPostedId($value)
  240.     {
  241.         $this->postedId $value;
  242.         return $this;
  243.     }
  244.     /**
  245.      * @return string
  246.      */
  247.     public function getPostedDetails()
  248.     {
  249.         return $this->postedDetails;
  250.     }
  251.     /**
  252.      * @param string $value
  253.      * @return $this
  254.      */
  255.     public function setPostedDetails($value)
  256.     {
  257.         $this->postedDetails $value;
  258.         return $this;
  259.     }
  260.     /**
  261.      * @return int
  262.      */
  263.     public function getStatus()
  264.     {
  265.         return $this->status;
  266.     }
  267.     /**
  268.      * @param int $value
  269.      * @return $this
  270.      */
  271.     public function setStatus($value)
  272.     {
  273.         $this->status $value;
  274.         return $this;
  275.     }
  276.     /**
  277.      * @return string
  278.      */
  279.     public function getErrorTrace()
  280.     {
  281.         return $this->errorTrace;
  282.     }
  283.     /**
  284.      * @param string $value
  285.      * @return $this
  286.      */
  287.     public function setErrorTrace($value)
  288.     {
  289.         $this->errorTrace $value;
  290.         return $this;
  291.     }
  292. }