Advertisement
Eddz

Untitled

Sep 2nd, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.25 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Fcm\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\ORM\Events;
  7. use Doctrine\ORM\Mapping\ManyToOne;
  8.  
  9. /**
  10.  *  @ORM\Table(name="campaign")
  11.  *  @ORM\Entity(repositoryClass="Fcm\Entity\Repository\CampaignRepository")
  12.  *  @ORM\HasLifecycleCallbacks
  13.  *  @property integer $id
  14.  *  @property string $name
  15.  *  @property string $status
  16.  *  @property string $expectedClose
  17.  *  @property integer $typeCampaign
  18.  *  @property integer $appId
  19.  *  @property string $appSecret
  20.  *  @property string $appUrl
  21.  *  @property string $appUrl
  22.  *  @property string $cssFileUrl
  23.  *  @property string $imgFileUrl
  24.  *  @property date $created
  25.  *  @property date $updated
  26.  */
  27. class Campaign
  28. {
  29.  
  30.     /**
  31.      * @ORM\Id
  32.      * @ORM\GeneratedValue(strategy="AUTO")
  33.      * @ORM\Column(type="integer")
  34.      */
  35.     protected $id;
  36.  
  37.     /** @ORM\Column(type="string", length=120, nullable=false) */
  38.     protected $name;
  39.  
  40.     /** @ORM\Column(type="boolean", nullable=false) */
  41.     protected $status;
  42.  
  43.     /** @ORM\Column(type="date", nullable=false) */
  44.     protected $startDate;
  45.  
  46.     /** @ORM\Column(type="date", nullable=false) */
  47.     protected $endDate;
  48.  
  49.     /** @ORM\Column(type="bigint", unique=false, nullable=false) */
  50.     protected $appId;
  51.  
  52.     /** @ORM\Column(type="string",length=125, nullable=true, unique=false) */
  53.     protected $appSecret;
  54.  
  55.     /** @ORM\Column(type="string",length=125, nullable=true, unique=false) */
  56.     protected $appUrl;
  57.  
  58.     /** @ORM\Column(type="text", nullable=true, unique=false) */
  59.     protected $content_landing_textarea;
  60.    
  61.     /** @ORM\Column(type="text", nullable=true, unique=false) */
  62.     protected $content_enter_textarea;
  63.    
  64.     /** @ORM\Column(type="text", nullable=true, unique=false) */
  65.     protected $content_term_policy;
  66.  
  67.     /** @ORM\Column(type="text", nullable=true, unique=false) */
  68.     protected $content_thank_you;
  69.  
  70.     /** @ORM\Column(type="string",length=200,nullable=true, unique=false) */
  71.     protected $share_title;
  72.  
  73.     /** @ORM\Column(type="string",length=200, nullable=true, unique=false) */
  74.     protected $share_subtitle;
  75.  
  76.     /** @ORM\Column(type="string",length=200, nullable=true, unique=false) */
  77.     protected $share_desc;
  78.    
  79.     /** @ORM\Column(type="bigint", unique=false, nullable=false) */
  80.     protected $version;
  81.  
  82.     /**
  83.      *  @ORM\ManyToOne(targetEntity="Client",inversedBy="campaigns")
  84.      *  @ORM\JoinColumn(onDelete="CASCADE")
  85.      */
  86.     protected $client;
  87.  
  88.     /** @ORM\OneToMany(targetEntity="Response", mappedBy="campaign", cascade={"remove"}) */
  89.     protected $responses;
  90.  
  91.     /**
  92.      * @ORM\OneToOne(targetEntity="Asset", mappedBy="campaign",cascade={"remove"})
  93.      */
  94.     protected $assets;
  95.  
  96.     /**
  97.      * @ORM\OneToOne(targetEntity="AnswerQuestion", mappedBy="campaign", cascade={"remove"})
  98.      */
  99.     protected $answer_question;
  100.  
  101.     /**
  102.      * @ORM\OneToOne(targetEntity="Draw", mappedBy="campaign", cascade={"persist", "remove"})
  103.      */
  104.     protected $draw;
  105.  
  106.     /**
  107.      * @ORM\OneToOne(targetEntity="DesiredField", mappedBy="campaign", cascade={"remove"})
  108.      */
  109.     protected $desired_field;
  110.  
  111.     /**
  112.      * @ORM\OneToOne(targetEntity="MultipleChoice", mappedBy="campaign", cascade={"remove"})
  113.      */
  114.     protected $multiple_choice;
  115.  
  116.     /**
  117.      *  @ORM\ManyToOne(targetEntity="TypeCampaign", inversedBy="campaign")
  118.      */
  119.     protected $typeCampaign;
  120.  
  121.     /**
  122.      * @var date $created
  123.      *
  124.      * @ORM\Column(name="created", type="date", nullable=false)
  125.      */
  126.     protected $created;
  127.  
  128.     /**
  129.      * @var date $updated
  130.      *
  131.      * @ORM\Column(name="updated", type="date", nullable=false)
  132.      */
  133.     protected $updated;
  134.  
  135.     /**
  136.      * Magic getter to expose protected properties.
  137.      *
  138.      * @param string $property
  139.      * @return mixed
  140.      */
  141.     public function __get($property)
  142.     {
  143.         return $this->$property;
  144.     }
  145.  
  146.     /**
  147.      * Magic setter to save protected properties.
  148.      *
  149.      * @param string $property
  150.      * @param mixed $value
  151.      */
  152.     public function __set($property, $value)
  153.     {
  154.         $this->$property = $value;
  155.     }
  156.  
  157.     /**
  158.      * Convert the object to an array.
  159.      *
  160.      * @return array
  161.      */
  162.     public function getArrayCopy()
  163.     {
  164.         return get_object_vars($this);
  165.     }
  166.  
  167.     /**
  168.      * Populate from entity to array an array.
  169.      *
  170.      * @param array $data
  171.      */
  172.     public function toArray()
  173.     {
  174.         $data = array(
  175.             'fsInfoCampaign' => array(
  176.                 'id' => $this->id,
  177.                 'name' => $this->name,
  178.                 'status' => $this->status,
  179.                 'startdate' => $this->startDate->format('Y-m-d'),
  180.                 'enddate' => $this->endDate->format('Y-m-d'),
  181.                 'typecampaign' => $this->typeCampaign->type,
  182.                 'typecampaignid' => $this->typeCampaign->id,
  183.                 'client' => $this->client->name,
  184.                 'clientid' => $this->client->id,
  185.                 'version' => $this->version
  186.             ),
  187.             'fsFB' => array(
  188.                 'appid' => $this->appId,
  189.                 'appsecret' => $this->appSecret,
  190.                 'appurl' => $this->appUrl,
  191.                 'landing_textarea' => $this->content_landing_textarea,
  192.                 'enter_textarea' => $this->content_enter_textarea,
  193.                 'term_privacy_textarea' => $this->content_term_policy,
  194.                 'thank_you_textarea' => $this->content_thank_you,
  195.                 'title_share_Text' => $this->share_title,
  196.                 'subtitle_share_text' => $this->share_subtitle,
  197.                 'desc_share_textarea' => $this->share_desc,
  198.             ),
  199.         );
  200.        
  201.         return $data;
  202.     }
  203.  
  204.     /**
  205.      * Populate from an array.
  206.      *
  207.      * @param array $data
  208.      */
  209.     public function populate($data = array())
  210.     {
  211.         // fsInfoCampaign
  212.         $this->name = $data['fsInfoCampaign']['name'];
  213.         $this->status = $data['fsInfoCampaign']['status'];
  214.         $this->startDate = new \DateTime($data['fsInfoCampaign']['startdate']);
  215.         $this->endDate = new \DateTime($data['fsInfoCampaign']['enddate']);
  216.         $this->client = $data['fsInfoCampaign']['client'];
  217.         $this->typeCampaign = $data['fsInfoCampaign']['typecampaign'];
  218.         $this->version = $data['fsInfoCampaign']['version'];
  219.         // fsFB
  220.         $this->appId = $data['fsFB']['appid'];
  221.         $this->appSecret = $data['fsFB']['appsecret'];
  222.         $this->appUrl = $data['fsFB']['appurl'];
  223.         $this->content_landing_textarea = $data['fsFB']['landing_textarea'];
  224.         $this->content_enter_textarea = $data['fsFB']['enter_textarea'];
  225.         $this->content_term_policy = $data['fsFB']['term_privacy_textarea'];
  226.         $this->content_thank_you = $data['fsFB']['thank_you_textarea'];
  227.         $this->share_title = $data['fsFB']['title_share_Text'];
  228.         $this->share_subtitle = $data['fsFB']['subtitle_share_text'];
  229.         $this->share_desc = $data['fsFB']['desc_share_textarea'];
  230.     }
  231.  
  232.     /** @ORM\PrePersist */
  233.     public function onPrePersist()
  234.     {
  235.         $this->created = $this->updated = new \DateTime('now');
  236.     }
  237.  
  238.     /** @ORM\PreUpdate */
  239.     public function onPreUpdate()
  240.     {
  241.         $this->updated = new \DateTime('now');
  242.     }
  243.  
  244. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement