src/Diplix/KMGBundle/Entity/Address.php line 416

Open in your IDE?
  1. <?php
  2. namespace Diplix\KMGBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Imagine\Exception\NotSupportedException;
  5. use Symfony\Component\PropertyAccess\PropertyAccess;
  6. /**
  7.  * @ORM\Table(name="addresses", indexes={@ORM\Index(name="be_deleted",columns={"be_deleted"})})
  8.  * @ORM\Entity(repositoryClass="Diplix\KMGBundle\Repository\AddressRepository", )
  9.  */
  10. class Address extends BasicEntity implements \JsonSerializable
  11. {
  12.     const WAYPOINT_IN "Einstieg";
  13.     const WAYPOINT_OUT "Ausstieg";
  14.     /**
  15.      * @ORM\Column(type="integer",name="id")
  16.      * @ORM\Id()
  17.      * @ORM\GeneratedValue(strategy="AUTO")
  18.      */
  19.     protected $id;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity="Order", inversedBy="addressList")
  22.      * @ORM\JoinColumn(referencedColumnName="id")
  23.      */
  24.     protected $owningOrder;
  25.     /**
  26.      * @ORM\Column(type="string")
  27.      */
  28.     protected $waypointType self::WAYPOINT_IN;
  29.     /**
  30.      * @ORM\Column(type="string")
  31.      */
  32.     protected $name;
  33.     /**
  34.      * @ORM\Column(type="string")
  35.      */
  36.     protected $passenger="";
  37.     /**
  38.      * @ORM\Column(type="string")
  39.      */
  40.     protected $street;
  41.     /**
  42.      * @ORM\Column(type="string")
  43.      */
  44.     protected $number;
  45.     /**
  46.      * @ORM\Column(type="string")
  47.      */
  48.     protected $zipCode;
  49.     /**
  50.      * @ORM\Column(type="string")
  51.      */
  52.     protected $city;
  53.     /**
  54.      * @ORM\Column(type="string")
  55.      */
  56.     protected $mobileNumber "";
  57.     /**
  58.      * @ORM\Column(type="string")
  59.      */
  60.     protected $creditCardNo "";
  61.     /**
  62.      * @ORM\Column(type="string")
  63.      */
  64.     protected $creditCardMonth "";
  65.     /**
  66.      * @ORM\Column(type="string")
  67.      */
  68.     protected $creditCardYear "";
  69.      /**
  70.       * A address may be assigned to a customer, but it doesn't have to
  71.      * @ORM\ManyToOne(targetEntity="Customer")
  72.      * @ORM\JoinColumn(name="customer_id",nullable=true)
  73.      */
  74.     protected $customer;
  75.     /**
  76.      * @ORM\Column(type="integer")
  77.      */
  78.     protected $sortOrder 0;
  79.     /**
  80.      * @ORM\ManyToOne(targetEntity="Diplix\KMGBundle\Entity\AddressType")
  81.      * @ORM\JoinColumn(referencedColumnName="id")
  82.      */
  83.     protected $addressType;
  84.     /**
  85.      * @ORM\Column(type="string")
  86.      */
  87.     protected $email "";
  88.     /**
  89.      * @ORM\Column(type="boolean", options={"default"="0"})
  90.      */
  91.     protected $fixedBySystem false;
  92.     public function __construct($customer=null$sortOrder=0)
  93.     {
  94.         $this->setCustomer($customer);
  95.         $this->setSortOrder($sortOrder);
  96.     }
  97.     public function __clone()
  98.     {
  99.         $this->owningOrder null;
  100.         $this->id null;
  101.     }
  102.     /**
  103.      * @return mixed
  104.      */
  105.     public function getId()
  106.     {
  107.         return $this->id;
  108.     }
  109.     /**
  110.      * @return mixed
  111.      */
  112.     public function getOwningOrder()
  113.     {
  114.         return $this->owningOrder;
  115.     }
  116.     /**
  117.      * @param mixed $owningOrder
  118.      */
  119.     public function setOwningOrder($owningOrder)
  120.     {
  121.         $this->owningOrder $owningOrder;
  122.     }
  123.     /**
  124.      * @return mixed
  125.      */
  126.     public function getWaypointType()
  127.     {
  128.         return $this->waypointType;
  129.     }
  130.     /**
  131.      * @param mixed $waypointType
  132.      */
  133.     public function setWaypointType($waypointType)
  134.     {
  135.         $this->waypointType $waypointType;
  136.     }
  137.     /**
  138.      * @return mixed
  139.      */
  140.     public function getName()
  141.     {
  142.         return $this->name;
  143.     }
  144.     /**
  145.      * @param mixed $name
  146.      */
  147.     public function setName($name)
  148.     {
  149.         $this->name $name;
  150.     }
  151.     /**
  152.      * @return mixed
  153.      */
  154.     public function getStreet()
  155.     {
  156.         return $this->street;
  157.     }
  158.     /**
  159.      * @param mixed $street
  160.      */
  161.     public function setStreet($street)
  162.     {
  163.         $this->street $street;
  164.     }
  165.     /**
  166.      * @return mixed
  167.      */
  168.     public function getNumber()
  169.     {
  170.         return $this->number;
  171.     }
  172.     /**
  173.      * @param mixed $number
  174.      */
  175.     public function setNumber($number)
  176.     {
  177.         $this->number $number;
  178.     }
  179.     /**
  180.      * @return mixed
  181.      */
  182.     public function getZipCode()
  183.     {
  184.         return $this->zipCode;
  185.     }
  186.     /**
  187.      * @param mixed $zipCode
  188.      */
  189.     public function setZipCode($zipCode)
  190.     {
  191.         $this->zipCode $zipCode;
  192.     }
  193.     /**
  194.      * @return mixed
  195.      */
  196.     public function getCity()
  197.     {
  198.         return $this->city;
  199.     }
  200.     /**
  201.      * @param mixed $city
  202.      */
  203.     public function setCity($city)
  204.     {
  205.         $this->city $city;
  206.     }
  207.     /**
  208.      * @return mixed
  209.      */
  210.     public function getCustomer()
  211.     {
  212.         return $this->customer;
  213.     }
  214.     /**
  215.      * @param mixed $customer
  216.      */
  217.     public function setCustomer($customer)
  218.     {
  219.         $this->customer $customer;
  220.     }
  221.     /**
  222.      * @return mixed
  223.      */
  224.     public function getSortOrder()
  225.     {
  226.         return $this->sortOrder;
  227.     }
  228.     /**
  229.      * @param mixed $sortOrder
  230.      */
  231.     public function setSortOrder($sortOrder)
  232.     {
  233.         $this->sortOrder $sortOrder;
  234.     }
  235.     /**
  236.      * @return mixed
  237.      */
  238.     public function getPassenger()
  239.     {
  240.         return $this->passenger;
  241.     }
  242.     /**
  243.      * @param mixed $passenger
  244.      */
  245.     public function setPassenger($passenger)
  246.     {
  247.         $this->passenger $passenger;
  248.     }
  249.     /**
  250.      * @return AddressType
  251.      */
  252.     public function getAddressType()
  253.     {
  254.         return $this->addressType;
  255.     }
  256.     /**
  257.      * @param AddressType $addressType
  258.      */
  259.     public function setAddressType($addressType)
  260.     {
  261.         $this->addressType $addressType;
  262.     }
  263.     /**
  264.      * @return mixed
  265.      */
  266.     public function getMobileNumber()
  267.     {
  268.         return $this->mobileNumber;
  269.     }
  270.     /**
  271.      * @param mixed $mobileNumber
  272.      */
  273.     public function setMobileNumber($mobileNumber)
  274.     {
  275.         $this->mobileNumber $mobileNumber;
  276.     }
  277.     /**
  278.      * @return mixed
  279.      */
  280.     public function getCreditCardNo()
  281.     {
  282.         return $this->creditCardNo;
  283.     }
  284.     /**
  285.      * @param mixed $creditCardNo
  286.      */
  287.     public function setCreditCardNo($creditCardNo)
  288.     {
  289.         $this->creditCardNo $creditCardNo;
  290.     }
  291.     /**
  292.      * @return mixed
  293.      */
  294.     public function getCreditCardMonth()
  295.     {
  296.         return $this->creditCardMonth;
  297.     }
  298.     /**
  299.      * @param mixed $creditCardMonth
  300.      */
  301.     public function setCreditCardMonth($creditCardMonth)
  302.     {
  303.         $this->creditCardMonth $creditCardMonth;
  304.     }
  305.     /**
  306.      * @return mixed
  307.      */
  308.     public function getCreditCardYear()
  309.     {
  310.         return $this->creditCardYear;
  311.     }
  312.     /**
  313.      * @param mixed $creditCardYear
  314.      */
  315.     public function setCreditCardYear($creditCardYear)
  316.     {
  317.         $this->creditCardYear $creditCardYear;
  318.     }
  319.     /**
  320.      * @return mixed
  321.      */
  322.     public function getEmail()
  323.     {
  324.         return $this->email;
  325.     }
  326.     /**
  327.      * @param mixed $email
  328.      */
  329.     public function setEmail($email)
  330.     {
  331.         $this->email $email;
  332.     }
  333.     /**
  334.      * @return boolean
  335.      */
  336.     public function getFixedBySystem()
  337.     {
  338.         return $this->fixedBySystem;
  339.     }
  340.     /**
  341.      * @param boolean $fixedBySystem
  342.      */
  343.     public function setFixedBySystem($fixedBySystem)
  344.     {
  345.         $this->fixedBySystem $fixedBySystem;
  346.     }
  347.     /**
  348.      * Specify data which should be serialized to JSON
  349.      * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
  350.      * @return mixed data which can be serialized by <b>json_encode</b>,
  351.      * which is a value of any type other than a resource.
  352.      * @since 5.4.0
  353.      */
  354.     function jsonSerialize($prefix "")
  355.     {
  356.         return [
  357.             $prefix."email" => $this->getEmail(),
  358.             $prefix."street" => $this->getStreet(),
  359.             $prefix."number" => $this->getNumber(),
  360.             $prefix."city"=> $this->getCity(),
  361.             $prefix."zipCode" => $this->getZipCode(),
  362.             $prefix."name"=>$this->getName(),
  363.             $prefix."passenger"=>$this->getPassenger(),
  364.             $prefix."sortOrder"=>$this->getSortOrder(),
  365.             $prefix."mobileNumber"=>$this->getMobileNumber(),
  366.         ];
  367.     }
  368.     function fromJson(array $data)
  369.     {
  370.         $pp PropertyAccess::createPropertyAccessor();
  371.         foreach(["email","street","number","city","zipCode","name","passenger","sortOrder","mobileNumber"] as $k)
  372.         {
  373.             if (isset($data[$k]))
  374.             {
  375.                 $pp->setValue($this,$k,$data[$k]);
  376.             }
  377.         }
  378.     }
  379. }