src/Entity/Feed/FeedElement.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Feed;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Symfony\Component\HttpFoundation\File\UploadedFile;
  6. use Symfony\Component\Filesystem\Filesystem;
  7. //use Symfony\Component\Intl\Intl;
  8. use Symfony\Component\Intl\Countries;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. /**
  11.  * FeedElement
  12.  *
  13.  * @ORM\Table(name="tam_feed_element")
  14.  * @ORM\Entity(repositoryClass="App\Repository\Feed\FeedElementRepository")
  15.  * @ORM\HasLifecycleCallbacks
  16.  */
  17. class FeedElement
  18. {
  19.     /**
  20.      * @var int
  21.      *
  22.      * @ORM\Column(name="id", type="integer")
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue(strategy="IDENTITY")
  25.      */
  26.     private $id;
  27.     
  28.     /**
  29.      * @var \App\Entity\User
  30.      *
  31.      * @ORM\ManyToOne(targetEntity="\App\Entity\User", fetch="EAGER", inversedBy="feedElements")
  32.      * @ORM\JoinColumns({
  33.      *   @ORM\JoinColumn(name="tam_user", referencedColumnName="id", onDelete="SET NULL")
  34.      * })
  35.      */
  36.     private $user;
  37.     
  38.     /**
  39.      * @var \App\Entity\Feed\FeedElementType
  40.      *
  41.      * @ORM\ManyToOne(targetEntity="\App\Entity\Feed\FeedElementType", fetch="EAGER", inversedBy="feedElements")
  42.      * @ORM\JoinColumns({
  43.      *   @ORM\JoinColumn(name="feed_element_type", referencedColumnName="id", onDelete="SET NULL")
  44.      * })
  45.      */
  46.     private $feedElementType;
  47.     
  48.     /**
  49.      * @var string
  50.      *
  51.      * @ORM\Column(name="title", type="string", length=255, nullable=true)
  52.      */
  53.     private $title;
  54.     
  55.     /**
  56.      * @var string
  57.      *
  58.      * @ORM\Column(name="description", type="text", nullable=true)
  59.      */
  60.     private $description;
  61.     
  62.     /**
  63.      * @var string
  64.      *
  65.      * @ORM\Column(name="place_name", type="string", length=255, nullable=true)
  66.      */
  67.     private $placeName;
  68.     
  69.     /**
  70.      * @var string
  71.      *
  72.      * @ORM\Column(name="place_address", type="string", length=255, nullable=true)
  73.      */
  74.     private $placeAddress;
  75.     
  76.     /**
  77.      * @var string
  78.      *
  79.      * @ORM\Column(name="place_zipcode", type="string", length=255, nullable=true)
  80.      */
  81.     private $placeZipcode;
  82.     
  83.     /**
  84.      * @var string
  85.      *
  86.      * @ORM\Column(name="place_city", type="string", length=255, nullable=true)
  87.      */
  88.     private $placeCity;
  89.     
  90.     /**
  91.      * @var string
  92.      *
  93.      * @ORM\Column(name="place_country", type="string", length=255, nullable=true)
  94.      */
  95.     private $placeCountry;
  96.     
  97.     /**
  98.      * @var string
  99.      *
  100.      * @ORM\Column(name="lat", type="decimal", precision=14, scale=10, nullable=true)
  101.      */
  102.     private $lat;
  103.     /**
  104.      * @var string
  105.      *
  106.      * @ORM\Column(name="lng", type="decimal", precision=14, scale=10, nullable=true)
  107.      */
  108.     private $lng;
  109.     
  110.     /**
  111.      * @var geography
  112.      *
  113.      * @ORM\Column(name="coordinates", type="geography", nullable=true, options={"geometry_type"="POINT", "srid"=4326})
  114.      */
  115.     private $coordinates;
  116.     
  117.     /**
  118.      * @var \DateTime
  119.      *
  120.      * @ORM\Column(name="date_created", type="datetime", nullable=false)
  121.      */
  122.     private $dateCreated;
  123.     
  124.     /**
  125.      * @var \DateTime
  126.      *
  127.      * @ORM\Column(name="date_updated", type="datetime", nullable=true)
  128.      */
  129.     private $dateUpdated;
  130.     
  131.     /**
  132.      * @var boolean
  133.      *
  134.      * @ORM\Column(name="active", type="boolean", options={"default": FALSE})
  135.      */
  136.     private $active;
  137.     
  138.     /**
  139.      * @ORM\OneToOne(targetEntity="\App\Entity\Tam\Tam", mappedBy="feedElement", cascade={"persist", "remove"})
  140.      */
  141.     private $tam;
  142.     
  143.     /**
  144.      * @ORM\OneToOne(targetEntity="\App\Entity\Feed\Advert", mappedBy="feedElement", cascade={"persist", "remove"})
  145.      */
  146.     private $advert;
  147.     
  148.     /**
  149.      * @ORM\OneToOne(targetEntity="\App\Entity\Feed\FeedTransaction", mappedBy="feedElement", cascade={"persist", "remove"})
  150.      */
  151.     private $transaction;
  152.     
  153.     /**
  154.      * @var string
  155.      *
  156.      * @ORM\Column(name="illustration", type="string", length=255, nullable=true)
  157.      */
  158.     private $illustration;
  159.     
  160.      /**
  161.      * Image illustrationFile
  162.      *
  163.      * @var File
  164.      *
  165.      * @Assert\File(
  166.      *     maxSize = "5M",
  167.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/tiff"},
  168.      *     maxSizeMessage = "The maxmimum allowed file size is 5MB.",
  169.      *     mimeTypesMessage = "Only the filetypes image are allowed."
  170.      * )
  171.      */
  172.     protected $illustrationFile;
  173.     
  174.     
  175.     /**
  176.      * @var ArrayCollection
  177.      *
  178.      * @ORM\OneToMany(targetEntity="\App\Entity\Feed\FeedMessage", mappedBy="feedElement", cascade={"persist", "remove"})
  179.      */
  180.     private $messages;
  181.     
  182.     /**
  183.      * @var float
  184.      *
  185.      */
  186.     private $distance;
  187.     
  188.     
  189.     public function __construct()
  190.     {
  191.         $this->active true;
  192.         $this->dateCreated = new \DateTime();
  193.         $this->dateUpdated = new \DateTime();
  194.         $this->illustrationFile null;
  195.         $this->messages = new ArrayCollection();
  196.         $this->distance 0;
  197.     }
  198.     /**
  199.      * Get id
  200.      *
  201.      * @return int
  202.      */
  203.     public function getId()
  204.     {
  205.         return $this->id;
  206.     }
  207.     
  208.     /**
  209.      * Set user
  210.      *
  211.      * @param User $user
  212.      *
  213.      * @return FeedElement
  214.      */
  215.     public function setUser($user)
  216.     {
  217.         $this->user $user;
  218.         return $this;
  219.     }
  220.     /**
  221.      * Get user
  222.      *
  223.      * @return User
  224.      */
  225.     public function getUser()
  226.     {
  227.         return $this->user;
  228.     }
  229.     
  230.     /**
  231.      * Set feedElementType
  232.      *
  233.      * @param FeedElementType $feedElementType
  234.      *
  235.      * @return FeedElement
  236.      */
  237.     public function setFeedElementType($feedElementType)
  238.     {
  239.         $this->feedElementType $feedElementType;
  240.         return $this;
  241.     }
  242.     /**
  243.      * Get feedElementType
  244.      *
  245.      * @return FeedElementType
  246.      */
  247.     public function getFeedElementType()
  248.     {
  249.         return $this->feedElementType;
  250.     }
  251.     
  252.     /**
  253.      * Set title
  254.      *
  255.      * @param string $title
  256.      *
  257.      * @return FeedElement
  258.      */
  259.     public function setTitle($title)
  260.     {
  261.         $this->title $title;
  262.         return $this;
  263.     }
  264.     /**
  265.      * Get title
  266.      *
  267.      * @return string
  268.      */
  269.     public function getTitle()
  270.     {
  271.         return $this->title;
  272.     }
  273.     
  274.     /**
  275.      * Set description
  276.      *
  277.      * @param string $description
  278.      *
  279.      * @return FeedElement
  280.      */
  281.     public function setDescription($description)
  282.     {
  283.         $this->description $description;
  284.         return $this;
  285.     }
  286.     /**
  287.      * Get description
  288.      *
  289.      * @return string
  290.      */
  291.     public function getDescription()
  292.     {
  293.         return $this->description;
  294.     }
  295.     
  296.     /**
  297.      * Set placeName
  298.      *
  299.      * @param string $placeName
  300.      *
  301.      * @return FeedElement
  302.      */
  303.     public function setPlaceName($placeName)
  304.     {
  305.         $this->placeName $placeName;
  306.         return $this;
  307.     }
  308.     /**
  309.      * Get placeName
  310.      *
  311.      * @return string
  312.      */
  313.     public function getPlaceName()
  314.     {
  315.         return $this->placeName;
  316.     }
  317.     
  318.     /**
  319.      * Set placeAddress
  320.      *
  321.      * @param string $placeAddress
  322.      *
  323.      * @return FeedElement
  324.      */
  325.     public function setPlaceAddress($placeAddress)
  326.     {
  327.         $this->placeAddress $placeAddress;
  328.         return $this;
  329.     }
  330.     /**
  331.      * Get placeAddress
  332.      *
  333.      * @return string
  334.      */
  335.     public function getPlaceAddress()
  336.     {
  337.         return $this->placeAddress;
  338.     }
  339.     
  340.     /**
  341.      * Set placeZipcode
  342.      *
  343.      * @param string $placeZipcode
  344.      *
  345.      * @return FeedElement
  346.      */
  347.     public function setPlaceZipcode($placeZipcode)
  348.     {
  349.         $this->placeZipcode $placeZipcode;
  350.         return $this;
  351.     }
  352.     /**
  353.      * Get placeZipcode
  354.      *
  355.      * @return string
  356.      */
  357.     public function getPlaceZipcode()
  358.     {
  359.         return $this->placeZipcode;
  360.     }
  361.     
  362.     /**
  363.      * Set placeCity
  364.      *
  365.      * @param string $placeCity
  366.      *
  367.      * @return FeedElement
  368.      */
  369.     public function setPlaceCity($placeCity)
  370.     {
  371.         $this->placeCity $placeCity;
  372.         return $this;
  373.     }
  374.     /**
  375.      * Get placeCity
  376.      *
  377.      * @return string
  378.      */
  379.     public function getPlaceCity()
  380.     {
  381.         return $this->placeCity;
  382.     }
  383.     
  384.     /**
  385.      * Set placeCountry
  386.      *
  387.      * @param string $placeCountry
  388.      *
  389.      * @return FeedElement
  390.      */
  391.     public function setPlaceCountry($placeCountry)
  392.     {
  393.         $this->placeCountry $placeCountry;
  394.         return $this;
  395.     }
  396.     /**
  397.      * Get placeCountry
  398.      *
  399.      * @return string
  400.      */
  401.     public function getPlaceCountry()
  402.     {
  403.         return $this->placeCountry;
  404.     }
  405.     
  406.     /**
  407.      * Set lat
  408.      *
  409.      * @param string $lat
  410.      * @return FeedElement
  411.      */
  412.     public function setLat($lat)
  413.     {
  414.         $this->lat $lat;
  415.         return $this;
  416.     }
  417.     /**
  418.      * Get lat
  419.      *
  420.      * @return string 
  421.      */
  422.     public function getLat()
  423.     {
  424.         return $this->lat;
  425.     }
  426.     /**
  427.      * Set lng
  428.      *
  429.      * @param string $lng
  430.      * @return FeedElement
  431.      */
  432.     public function setLng($lng)
  433.     {
  434.         $this->lng $lng;
  435.         return $this;
  436.     }
  437.     /**
  438.      * Get lng
  439.      *
  440.      * @return string 
  441.      */
  442.     public function getLng()
  443.     {
  444.         return $this->lng;
  445.     }
  446.     
  447.     /**
  448.      * Set coordinates
  449.      *
  450.      * @param string $coordinates
  451.      * @return FeedElement
  452.      */
  453.     public function setCoordinates($coordinates)
  454.     {
  455.         $this->coordinates $coordinates;  
  456.         return $this;
  457.     }
  458.     /**
  459.      * Get coordinates
  460.      *
  461.      * @return \geography 
  462.      */
  463.     public function getCoordinates()
  464.     {
  465.         return $this->coordinates;
  466.     }
  467.     
  468.     /**
  469.      * Set dateCreated
  470.      *
  471.      * @param \DateTime $dateCreated
  472.      *
  473.      * @return FeedElement
  474.      */
  475.     public function setDateCreated($dateCreated)
  476.     {
  477.         $this->dateCreated $dateCreated;
  478.         return $this;
  479.     }
  480.     /**
  481.      * Get dateCreated
  482.      *
  483.      * @return \DateTime
  484.      */
  485.     public function getDateCreated()
  486.     {
  487.         return $this->dateCreated;
  488.     }
  489.     
  490.     /**
  491.      * Set dateUpdated
  492.      *
  493.      * @param \DateTime $dateUpdated
  494.      *
  495.      * @return FeedElement
  496.      */
  497.     public function setDateUpdated($dateUpdated)
  498.     {
  499.         $this->dateUpdated $dateUpdated;
  500.         return $this;
  501.     }
  502.     /**
  503.      * Get dateUpdated
  504.      *
  505.      * @return \DateTime
  506.      */
  507.     public function getDateUpdated()
  508.     {
  509.         return $this->dateUpdated;
  510.     }
  511.     
  512.      /**
  513.      * Set active
  514.      *
  515.      * @param boolean $active
  516.      *
  517.      * @return FeedElement
  518.      */
  519.     public function setActive($active)
  520.     {
  521.         $this->active $active;
  522.         return $this;
  523.     }
  524.     /**
  525.      * Get active
  526.      *
  527.      * @return boolean
  528.      */
  529.     public function getActive()
  530.     {
  531.         return $this->active;
  532.     }
  533.     
  534.     /**
  535.      * Set Tam
  536.      *
  537.      * @param \App\Entity\Tam\Tam $tam
  538.      *
  539.      * @return FeedElement
  540.      */
  541.     public function setTam(\App\Entity\Tam\Tam $tam)
  542.     {
  543.         $this->tam $tam;
  544.         return $this;
  545.     }
  546.     /**
  547.      * Get tam
  548.      *
  549.      * @return \App\Entity\Tam\Tam
  550.      */
  551.     public function getTam()
  552.     {
  553.         return $this->tam;
  554.     }
  555.     
  556.     
  557.     /**
  558.      * Set Advert
  559.      *
  560.      * @param \App\Entity\Feed\Advert $advert
  561.      *
  562.      * @return FeedElement
  563.      */
  564.     public function setAdvert(\App\Entity\Feed\Advert $advert)
  565.     {
  566.         $this->advert $advert;
  567.         return $this;
  568.     }
  569.     /**
  570.      * Get advert
  571.      *
  572.      * @return \App\Entity\Feed\Advert
  573.      */
  574.     public function getAdvert()
  575.     {
  576.         return $this->advert;
  577.     }
  578.     
  579.     
  580.     /**
  581.      * Set transaction
  582.      *
  583.      * @param \App\Entity\Feed\FeedTransaction $transaction
  584.      *
  585.      * @return FeedElement
  586.      */
  587.     public function setTransaction(\App\Entity\Feed\FeedTransaction $transaction)
  588.     {
  589.         $this->transaction $transaction;
  590.         return $this;
  591.     }
  592.     /**
  593.      * Get transaction
  594.      *
  595.      * @return \App\Entity\Feed\FeedTransaction
  596.      */
  597.     public function getTransaction()
  598.     {
  599.         return $this->transaction;
  600.     }
  601.     
  602.     
  603.     /**
  604.      * Set illustration
  605.      *
  606.      * @param string $illustration
  607.      *
  608.      * @return FeedElement
  609.      */
  610.     public function setIllustration($illustration)
  611.     {
  612.         $this->illustration $illustration;
  613.         return $this;
  614.     }
  615.     /**
  616.      * Get illustration
  617.      *
  618.      * @return string
  619.      */
  620.     public function getIllustration()
  621.     {
  622.         return $this->illustration;
  623.     }
  624.     
  625.     
  626.     public function getLinkIllustration()
  627.     {
  628.         if($this->getIllustration()){
  629.             if(file_exists($this->getUploadIllustrationRootDir().$this->getIllustration()))
  630.                 return $this->getIllustrationDir().$this->getIllustration();
  631.             else
  632.                 return '/assets/images/common/feed_default.png';
  633.         }else{
  634.             return '/assets/images/common/feed_default.png';
  635.         }
  636.     }
  637.     
  638.     public function getAbsolutePathIllustration()
  639.     {
  640.         if($this->getIllustration()){
  641.             if(file_exists($this->getUploadIllustrationRootDir().$this->getIllustration()))
  642.                 return $this->getUploadIllustrationRootDir().$this->getIllustrationPath();
  643.             else
  644.                 return null;
  645.         }else{
  646.             return null;
  647.         }
  648.     }
  649.     
  650.     
  651.     /**
  652.      * Sets avatarFile.
  653.      *
  654.      * @param UploadedFile $file
  655.      */
  656.     public function setIllustrationFile(UploadedFile $file null)
  657.     {
  658.         $this->illustrationFile $file;
  659.     }
  660.     
  661.     /**
  662.      * Get illustrationFile.
  663.      *
  664.      * @return UploadedFile
  665.      */
  666.     public function getIllustrationFile()
  667.     {
  668.         return $this->illustrationFile;
  669.     }
  670.     
  671.     /**
  672.      * Add message
  673.      *
  674.      * @param \App\Entity\Feed\FeedMessage $message
  675.      *
  676.      * @return FeedMessage
  677.      */
  678.     public function addMessage(\App\Entity\Feed\FeedMessage $message)
  679.     {
  680.         if (!$this->messages->contains($message)) {
  681.             $this->messages[] = $message;
  682.             $message->setFeedElement($this);
  683.         }
  684.         return $this;
  685.     }
  686.     /**
  687.      * Remove message
  688.      *
  689.      * @param \App\Entity\Feed\FeedMessage $message
  690.      */
  691.     public function removeMessage(\App\Entity\Feed\FeedMessage $message)
  692.     {
  693.         
  694.         if ($this->messages->contains($message)) {
  695.             $this->messages->removeElement($message);
  696.         }
  697.         
  698.         return $this;
  699.         
  700.     }
  701.     /**
  702.      * Get messages
  703.      *
  704.      * @return \Doctrine\Common\Collections\Collection
  705.      */
  706.     public function getMessages()
  707.     {
  708.         return $this->messages;
  709.     }
  710.     
  711.     
  712.     /**
  713.      * Set distance
  714.      *
  715.      * @param float $distance
  716.      *
  717.      * @return User
  718.      */
  719.     public function setDistance($distance)
  720.     {
  721.         $this->distance str_replace(",""."$distance);
  722.         return $this;
  723.     }
  724.     /**
  725.      * Get distance
  726.      *
  727.      * @return float
  728.      */
  729.     public function getDistance()
  730.     {
  731.         return $this->distance;
  732.     }
  733.     
  734.     /**
  735.      * Get stringDistance
  736.      *
  737.      * @return string
  738.      */
  739.     public function getStringDistance()
  740.     {
  741.         if($this->distance 1000){
  742.             return sprintf("%0.2f km"$this->distance/1000);
  743.         }else{
  744.             return sprintf("%0.2f m"$this->distance);
  745.         }
  746.     }
  747.     
  748.     /***********************
  749.      * Lifecycle Callbacks
  750.      ***********************/
  751.     /**
  752.      *
  753.      * @ORM\PrePersist()
  754.      * @ORM\PreUpdate()
  755.      */
  756.     public function preUpdate()
  757.     {
  758.         $this->setDateUpdated(new \DateTime());
  759.         if($this->getLng() && $this->getLat())
  760.             $this->setCoordinates('SRID=4326;POINT(' $this->getLng() . ' ' $this->getLat() . ')');
  761.         
  762.     }
  763.     
  764.     /**
  765.      * Called before saving the entity
  766.      * 
  767.      * @ORM\PrePersist()
  768.      * @ORM\PreUpdate()
  769.      */
  770.     public function preUpload()
  771.     {   
  772.         if (null !== $this->illustrationFile) {
  773.             // do whatever you want to generate a unique name
  774.             $filename sha1(uniqid(mt_rand(), true));
  775.             $this->illustration $filename.'.'.$this->illustrationFile->guessExtension();
  776.             $this->setDateUpdated(new \DateTime());
  777.         }
  778.     }
  779.     
  780.     /**
  781.      * Called before entity removal
  782.      *
  783.      * @ORM\PreRemove()
  784.      */
  785.     public function removeUpload()
  786.     {
  787.         if ($file $this->getAbsolutePathAvatar()) {
  788.             unlink($file); 
  789.         }
  790.     }
  791.     
  792.     /**
  793.      * Called after entity persistence
  794.      *
  795.      * @ORM\PostPersist()
  796.      * @ORM\PostUpdate()
  797.      */
  798.     public function upload()
  799.     {
  800.         // The file property can be empty if the field is not required
  801.         if (null === $this->illustrationFile) {
  802.             return;
  803.         }
  804.     
  805.         // Use the original file name here but you should
  806.         // sanitize it at least to avoid any security issues
  807.     
  808.         // move takes the target directory and then the
  809.         // target filename to move to
  810.         $this->illustrationFile->move(
  811.             $this->getUploadIllustrationRootDir(),
  812.             $this->illustration
  813.         );
  814.     
  815.         // Set the path property to the filename where you've saved the file
  816.         //$this->path = $this->file->getClientOriginalName();
  817.     
  818.         // Clean up the file property as you won't need it anymore
  819.         $this->illustrationFile null;
  820.     }
  821.     
  822.     
  823.     
  824.     
  825.     
  826.     /***********************
  827.      * OTHER FUNCTION
  828.      ***********************/
  829.      
  830.     public function isTam(){
  831.         if($this->getFeedElementType()->getCodeTranslate() == "FEED_ELEMENT_TAM")
  832.             return true;
  833.             
  834.         return false;
  835.     }
  836.     
  837.     public function isAdvert(){
  838.         if($this->getFeedElementType()->getCodeTranslate() == "FEED_ELEMENT_ADVERT")
  839.             return true;
  840.             
  841.         return false;
  842.     }
  843.     
  844.     public function isAdvertOccasion(){
  845.         if($this->getFeedElementType()->getCodeTranslate() == "FEED_ELEMENT_ADVERT_OCCASION")
  846.             return true;
  847.             
  848.         return false;
  849.     }
  850.     
  851.     public function isTournament(){
  852.         if($this->getFeedElementType()->getCodeTranslate() == "FEED_ELEMENT_TOURNAMENT")
  853.             return true;
  854.             
  855.         return false;
  856.     }
  857.      
  858.     public function getCountryName(){
  859.         //return Intl::getRegionBundle()->getCountryName($this->getPlaceCountry());
  860.         if($this->getPlaceCountry())
  861.             return Countries::getName($this->getPlaceCountry());
  862.             
  863.         return "";
  864.     }
  865.     
  866.     
  867.     public function getUploadIllustrationRootDir(){
  868.         
  869.         $logoDir __DIR__ '/../../../public/assets/feed/'.$this->getUser()->getId().'/';
  870.         
  871.         $fs = new Filesystem();
  872.         if ($fs->exists($logoDir) == false) {
  873.                 $fs->mkdir($logoDir);
  874.         }
  875.         
  876.         return $logoDir;
  877.     }
  878.     
  879.     public function getIllustrationDir()
  880.     {
  881.         return '/assets/feed/'.$this->getUser()->getId().'/';
  882.     }
  883.     
  884.     
  885.     public function getPlaceCountryName(){
  886.         //return Intl::getRegionBundle()->getCountryName($this->getPlaceCountry());
  887.         if($this->getPlaceCountry())
  888.             return Countries::getName($this->getPlaceCountry());
  889.             
  890.         return "";
  891.     }
  892.     
  893.     public function updateFromJson($jsonObject){
  894.         
  895.         if(isset($jsonObject->title)){
  896.             $this->setTitle($jsonObject->title);
  897.         }
  898.         
  899.         if(isset($jsonObject->description)){
  900.             $this->setDescription($jsonObject->description);
  901.         }
  902.         
  903.         if(isset($jsonObject->placeAddress)){
  904.             $this->setPlaceAddress($jsonObject->placeAddress);
  905.         }
  906.         
  907.         if(isset($jsonObject->placeCity)){
  908.             $this->setPlaceCity($jsonObject->placeCity);
  909.         }
  910.         
  911.         if(isset($jsonObject->placeCountry)){
  912.             $this->setPlaceCountry($jsonObject->placeCountry);
  913.         }
  914.     }
  915.     
  916.     public function getArrayForJson($schemeAndBaseURL){
  917.         $array = array();
  918.         $array['id'] = $this->getId();
  919.         $array['user'] = $this->getUser()->getSimpleArrayForJson($schemeAndBaseURL);
  920.         $array['typeFeed'] = $this->getFeedElementType()->getArrayForJson();
  921.         $array['title'] = $this->getTitle();
  922.         $array['description'] = $this->getDescription() ? $this->getDescription() : "";
  923.         $array['placeName'] = $this->getPlaceName() ? $this->getDescription() : "";
  924.         $array['placeAddress'] = $this->getPlaceAddress() ? $this->getPlaceAddress() : "";
  925.         $array['placeZipcode'] = $this->getPlaceZipcode() ? $this->getPlaceZipcode() : "";
  926.         $array['placeCity'] = $this->getPlaceCity() ? $this->getPlaceCity() : "";
  927.         $array['placeCountry'] = $this->getPlaceCountry() ? $this->getPlaceCountry() : "";
  928.         $array['placeCountryName'] = $this->getPlaceCountryName() ? $this->getPlaceCountryName() : $this->getUser()->getCountryName();
  929.         $array['lat'] = $this->getLat();
  930.         $array['lng'] = $this->getLng();
  931.         $array['distance'] = $this->getDistance();
  932.         $array['distanceLabel'] = $this->getStringDistance();
  933.         if($this->getDateCreated()){
  934.             $array['dateCreated'] = $this->getDateCreated()->format("Y-m-d\TH:i:sP");
  935.         }
  936.         if($this->getIllustration()){
  937.             $array['illustrationURL'] = $schemeAndBaseURL.$this->getLinkIllustration();
  938.         }
  939.         if($this->getTam())
  940.             $array['tam'] = $this->getTam()->getArrayForJson($schemeAndBaseURL);
  941.         if($this->getAdvert())
  942.             $array['advert'] = $this->getAdvert()->getArrayForJson($schemeAndBaseURL);
  943.         
  944.         if($this->getMessages()){
  945.             foreach($this->getMessages() as $message){
  946.                 $array['messages'][] = $message->getArrayForJson($schemeAndBaseURL);
  947.             }
  948.         }
  949.         
  950.         
  951.         return $array;
  952.         
  953.     }
  954.     
  955.     
  956. }