src/Daikin/BaseBundle/Entity/Objects.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Daikin\BaseBundle\Entity;
  3. use App\Daikin\BaseBundle\Entity\Interfaces\CompanyInterface;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use EHC\HTMLIdableBundle\Interfaces\HTMLIdableInterface;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9.  * @ORM\Entity
  10.  * @ORM\Table(name="objects")
  11.  */
  12. class Objects extends AbstractUserOwnedEntity implements HTMLIdableInterfaceCompanyInterface
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\Column(type="integer")
  17.      * @ORM\GeneratedValue(strategy="AUTO")
  18.      *
  19.      * @var integer $id
  20.      */
  21.     protected $id;
  22.     /**
  23.      * @Gedmo\Timestampable(on="create")
  24.      * @ORM\Column(type="integer", name="created_at")
  25.      *
  26.      * @var integer $createdAt
  27.      */
  28.     protected $createdAt;
  29.     /**
  30.      * @Gedmo\Timestampable(on="update")
  31.      * @ORM\Column(type="integer", name="updated_at")
  32.      *
  33.      * @var integer $updatedAt
  34.      */
  35.     protected $updatedAt;
  36.     /**
  37.      * @ORM\Column(type="integer", name="lastupdate")
  38.      *
  39.      * @var integer $lastupdate
  40.      */
  41.     protected $lastupdate;
  42.     /**
  43.      * @ORM\Column(type="string", name="objectname")
  44.      *
  45.      * @var string $objectname
  46.      */
  47.     protected $objectname;
  48.     /**
  49.      * @ORM\Column(type="string", name="contactperson", nullable=true)
  50.      *
  51.      * @var string $contactperson
  52.      */
  53.     protected $contactperson;
  54.     /**
  55.      * @ORM\Column(type="string", name="phone", nullable=true)
  56.      *
  57.      * @var string $phone
  58.      */
  59.     protected $phone;
  60.     /**
  61.      * @ORM\Column(type="string", name="address", nullable=true)
  62.      *
  63.      * @var string $address
  64.      */
  65.     protected $address;
  66.     /**
  67.      * @ORM\Column(type="string", name="street", nullable=true)
  68.      *
  69.      * @var string $street
  70.      */
  71.     protected $street;
  72.     /**
  73.      * @ORM\Column(length=6, nullable=true)
  74.      *
  75.      * @var integer $zip
  76.      */
  77.     protected $zip;
  78.     /**
  79.      * @ORM\Column(type="string", name="city", nullable=true)
  80.      *
  81.      * @var string $city
  82.      */
  83.     protected $city;
  84.     /**
  85.      * @ORM\Column(type="string", name="comment", nullable=true)
  86.      *
  87.      * @var string $comment
  88.      */
  89.     protected $comment;
  90.     /**
  91.      * @ORM\Column(type="float", name="longitude", nullable=true)
  92.      *
  93.      * @var string $longitude
  94.      */
  95.     protected $longitude;
  96.     /**
  97.      * @ORM\Column(type="float", name="latitude", nullable=true)
  98.      *
  99.      * @var string $latitude
  100.      */
  101.     protected $latitude;
  102.     /**
  103.      * @ORM\OneToMany(targetEntity="Objectsunit", mappedBy="object")
  104.      *
  105.      *  @var ArrayCollection $objectsunit
  106.      */
  107.     protected $objectunits;
  108.     /**
  109.      * @ORM\ManyToOne(targetEntity="Company", inversedBy="objects")
  110.      * @ORM\JoinColumn(name="companyid", nullable=false)
  111.     */
  112.     protected $company;
  113.     /**
  114.      * Constructs a new instance
  115.      */
  116.     public function __construct()
  117.     {
  118.        parent::__construct();
  119.        $this->createdAt time();
  120.        $this->updatedAt time();
  121.        $this->objectunits = new ArrayCollection();
  122.     }
  123.     public function __toString()
  124.     {
  125.         return $this->getObjectname();
  126.     }
  127.     /**
  128.      * Get id
  129.      *
  130.      * @return integer
  131.      */
  132.     public function getId()
  133.     {
  134.         return $this->id;
  135.     }
  136.     public function getHTMLId()
  137.     {
  138.       return 'object-'.$this->id;
  139.     }
  140.     /**
  141.      * Set createdAt
  142.      *
  143.      * @param integer $createdAt
  144.      */
  145.     public function setCreatedAt($createdAt)
  146.     {
  147.         $this->createdAt $createdAt;
  148.     }
  149.     /**
  150.      * Get createdAt
  151.      *
  152.      * @return integer
  153.      */
  154.     public function getCreatedAt()
  155.     {
  156.         return $this->createdAt;
  157.     }
  158.     /**
  159.      * Set updatedAt
  160.      *
  161.      * @param integer $updatedAt
  162.      */
  163.     public function setUpdatedAt($updatedAt)
  164.     {
  165.         $this->updatedAt $updatedAt;
  166.     }
  167.     /**
  168.      * Get updatedAt
  169.      *
  170.      * @return integer
  171.      */
  172.     public function getUpdatedAt()
  173.     {
  174.         return $this->updatedAt;
  175.     }
  176.     /**
  177.      * Set lastupdate
  178.      *
  179.      * @param integer $lastupdate
  180.      */
  181.     public function setLastupdate($lastupdate)
  182.     {
  183.         $this->lastupdate $lastupdate;
  184.     }
  185.     /**
  186.      * Get lastupdate
  187.      *
  188.      * @return integer
  189.      */
  190.     public function getLastupdate()
  191.     {
  192.         return $this->lastupdate;
  193.     }
  194.     /**
  195.      * Set objectname
  196.      *
  197.      * @param string $objectname
  198.      */
  199.     public function setObjectname($objectname)
  200.     {
  201.         $this->objectname $objectname;
  202.     }
  203.     /**
  204.      * Get objectname
  205.      *
  206.      * @return string
  207.      */
  208.     public function getObjectname()
  209.     {
  210.         return $this->objectname;
  211.     }
  212.     /**
  213.      * Set contactperson
  214.      *
  215.      * @param string $contactperson
  216.      */
  217.     public function setContactperson($contactperson)
  218.     {
  219.         $this->contactperson $contactperson;
  220.     }
  221.     /**
  222.      * Get contactperson
  223.      *
  224.      * @return string
  225.      */
  226.     public function getContactperson()
  227.     {
  228.         return $this->contactperson;
  229.     }
  230.     /**
  231.      * Set phone
  232.      *
  233.      * @param string $phone
  234.      */
  235.     public function setPhone($phone)
  236.     {
  237.         $this->phone $phone;
  238.     }
  239.     /**
  240.      * Get phone
  241.      *
  242.      * @return string
  243.      */
  244.     public function getPhone()
  245.     {
  246.         return $this->phone;
  247.     }
  248.     /**
  249.      * Generate address
  250.      */
  251.     public function setAddress()
  252.     {
  253.         $this->address $this->getStreet() . ', ' $this->getZip() . ', ' $this->getCity();
  254.     }
  255.     /**
  256.      * @param $address
  257.      * @return Objects
  258.      */
  259.     public function overrideAddress($address)
  260.     {
  261.         $this->address $address;
  262.         return $this;
  263.     }
  264.     /**
  265.      * Get address
  266.      *
  267.      * @return string
  268.      */
  269.     public function getAddress()
  270.     {
  271.         return $this->address;
  272.     }
  273.     /**
  274.      * Set street
  275.      *
  276.      * @param string $street
  277.      */
  278.     public function setStreet($street)
  279.     {
  280.         $this->street $street;
  281.     }
  282.     /**
  283.      * Get street
  284.      *
  285.      * @return string
  286.      */
  287.     public function getStreet()
  288.     {
  289.         return $this->street;
  290.     }
  291.     /**
  292.      * Set zip
  293.      *
  294.      * @param integer $zip
  295.      */
  296.     public function setZip($zip)
  297.     {
  298.         $this->zip $zip;
  299.     }
  300.     /**
  301.      * Get zip
  302.      *
  303.      * @return integer
  304.      */
  305.     public function getZip()
  306.     {
  307.         return $this->zip;
  308.     }
  309.     /**
  310.      * Set city
  311.      *
  312.      * @param string $city
  313.      */
  314.     public function setCity($city)
  315.     {
  316.         $this->city $city;
  317.     }
  318.     /**
  319.      * Get city
  320.      *
  321.      * @return string
  322.      */
  323.     public function getCity()
  324.     {
  325.         return $this->city;
  326.     }
  327.     /**
  328.      * Set comment
  329.      *
  330.      * @param string $comment
  331.      */
  332.     public function setComment($comment)
  333.     {
  334.         $this->comment $comment;
  335.     }
  336.     /**
  337.      * Get comment
  338.      *
  339.      * @return string
  340.      */
  341.     public function getComment()
  342.     {
  343.         return $this->comment;
  344.     }
  345.     /**
  346.      * Set longitude
  347.      *
  348.      * @param float $longitude
  349.      */
  350.     public function setLongitude($longitude)
  351.     {
  352.         $this->longitude $longitude;
  353.     }
  354.     /**
  355.      * Get longitude
  356.      *
  357.      * @return float
  358.      */
  359.     public function getLongitude()
  360.     {
  361.         return $this->longitude;
  362.     }
  363.     /**
  364.      * Set latitude
  365.      *
  366.      * @param float $latitude
  367.      */
  368.     public function setLatitude($latitude)
  369.     {
  370.         $this->latitude $latitude;
  371.     }
  372.     /**
  373.      * Get latitude
  374.      *
  375.      * @return float
  376.      */
  377.     public function getLatitude()
  378.     {
  379.         return $this->latitude;
  380.     }
  381.     /**
  382.      * Get objectunits
  383.      *
  384.      * @return ArrayCollection|Objectsunit[]
  385.      */
  386.     public function getObjectunits()
  387.     {
  388.         return $this->objectunits;
  389.     }
  390.     /**
  391.      * set Company
  392.      *
  393.      * @param \App\Daikin\BaseBundle\Entity\Company $company
  394.      * @return \App\Daikin\BaseBundle\Entity\Objects
  395.      */
  396.     public function setCompany(Company $company)
  397.     {
  398.         $this->company $company;
  399.         return $this;
  400.     }
  401.     /**
  402.      * get Company
  403.      *
  404.      * @return \App\Daikin\BaseBundle\Entity\Company
  405.      */
  406.     public function getCompany(): ?Company
  407.     {
  408.         return $this->company;
  409.     }
  410.     /**
  411.      * Get companyid
  412.      *
  413.      * @return integer
  414.      * @deprecated since version 2.1 - kept for compatibility
  415.      */
  416.     public function getCompanyid()
  417.     {
  418.         return $this->getCompany()->getId();
  419.     }
  420.     /**
  421.      * set deleted for the Object - if true, will recursivley delete
  422.      *
  423.      * @param boolean $deleted
  424.      * @return Object
  425.      */
  426.     public function setDeleted($deleted)
  427.     {
  428.         if ( (bool)$deleted )
  429.         {
  430.             foreach( $this->getObjectunits() as $objectunit )
  431.             {
  432.                 $objectunit->setDeleted(true);
  433.             }
  434.         }
  435.         return parent::setDeleted($deleted);
  436.     }
  437. }