2 namespace Statistical\Entity;
4 use Doctrine\ORM\Mapping as ORM;
9 * Statistical almost sound like a stat + test and a tickle, lol.
11 * @ORM\Table(name="lib_statistical")
17 * Can not archive records.
19 const ARCHIVE = false;
21 * Pull Synchronization Strategy for this table.
23 const PULL_SYNCH_STRATEGY = 'Build';
25 * Push Synchronization Strategy for this table.
27 const PUSH_SYNCH_STRATEGY = 'Build';
32 * @ORM\Column(type="integer");
33 * @ORM\GeneratedValue(strategy="AUTO")
38 /* ------------------------------------ Ownership ------------------------------------ */
40 * @ORM\ManyToOne(targetEntity="\Stock\Entity\Stock", cascade={"all"})
41 * @ORM\JoinColumn(nullable=false, name="stock_id")
46 /* ------------------------------------ Stats ------------------------------------ */
48 * @ORM\Column(type="boolean", nullable=true, name="deal_done");
54 * @ORM\Column(type="boolean", nullable=true, name="deal_not_done");
56 protected $dealnotdone;
60 * @ORM\Column(type="boolean", nullable=true, name="trade_centre");
62 protected $tradecentre;
65 * @ORM\ManyToOne(targetEntity="\User\Entity\Profile")
66 * @ORM\JoinColumn(nullable=true, name="from_profile_id")
68 protected $fromProfile;
71 * @ORM\Column(type="datetime");
77 * Initialize collections.
79 public function __construct()
81 $this->stock = new \Doctrine\Common\Collections\ArrayCollection();
85 * Magic getter to expose protected properties.
86 * @param string $property
89 public function __get($property)
91 return $this->$property;
95 * Magic setter to save protected properties.
96 * @param string $property
99 public function __set($property, $value)
101 $this->$property = $value;
108 public function setCreateTime()
110 $this->created = new \DateTime("now");
113 * Convert the object to an array.
114 * @param array $expand
115 * @param array $intersect
118 public function toArray(array $expand = array(), array $intersect = array())
120 $includeAll = empty($intersect);
122 ($includeAll || isset($intersect['id']))
123 && $data['id'] = $this->id;
124 ($includeAll || isset($intersect['stock']))
125 && $data['stock'] = $this->stock;
126 ($includeAll || isset($intersect['dealdone']))
127 && $data['dealdone'] = $this->dealdone;
128 ($includeAll || isset($intersect['dealnotdone']))
129 && $data['dealnotdone'] = $this->dealnotdone;
130 ($includeAll || isset($intersect['tradecentre']))
131 && $data['tradecentre'] = $this->tradecentre;
132 ($includeAll || isset($intersect['fromProfile']))
133 && $data['fromProfile'] = in_array('fromProfile', $expand)
134 && !is_null($this->fromProfile)
135 ? $this->fromProfile->toArray($expand, $intersect)
137 ($includeAll || isset($intersect['created']))
138 && $data['created'] = $this->created;
143 * Convert the object to an array for synchronization.
146 public function toSynchArray()
150 'stock' => $this->stock,
151 'dealdone' => $this->dealdone,
152 'dealnotdone' => $this->dealnotdone,
153 'tradecentre' => $this->tradecentre,
154 'fromProfile' => $this->fromProfile,
155 'created' => $this->created
160 * Populate from an array.
163 public function fromArray($data = array())
166 && $this->id = $data['id'];
167 isset($data['stock'])
168 && $this->stock = $data['stock'];
169 isset($data['dealdone'])
170 && $this->dealdone = $data['dealdone'];
171 isset($data['dealnotdone'])
172 && $this->dealnotdone = $data['dealnotdone'];
173 isset($data['tradecentre'])
174 && $this->tradecentre = $data['tradecentre'];
175 isset($data['fromProfile'])
176 && $this->fromProfile = $data['fromProfile'];
177 isset($data['created'])
178 && $this->created = $data['created'];