36 private static function createCollectionObject()
41 return new $className();
76 $bindingList = $entity::loadForOrder(
$order->getId());
78 foreach ($bindingList as $item)
92 public static function getList(array $parameters = array())
94 return TradingPlatform\OrderTable::getList($parameters);
101 public function createItem(TradingPlatform\
Platform $platform =
null)
108 $tradeBinding = $tradeBindingEntity::create($this, $platform);
109 $this->addItem($tradeBinding);
111 return $tradeBinding;
114 public function onItemModify(CollectableEntity $item, $name =
null, $oldValue =
null, $value =
null)
119 if ($item instanceof TradeBindingEntity)
124 return parent::onItemModify($item, $name, $oldValue, $value);
132 public function addItem(Internals\CollectableEntity $item)
134 if (!($item instanceof TradeBindingEntity))
136 throw new Main\NotSupportedException();
140 $entity = parent::addItem($item);
152 public function deleteItem($index)
155 $oldItem = parent::deleteItem($index);
166 public function save()
168 $result =
new Result();
173 throw new Main\ObjectNotFoundException(
'Entity "Order" not found');
178 $itemsFromDbList = static::getList(
180 "filter" => array(
"ORDER_ID" =>
$order->getId())
184 while ($item = $itemsFromDbList->fetch())
188 static::deleteInternal($item[
'ID']);
194 foreach ($this->collection as $entity)
196 $r = $entity->save();
197 if (!$r->isSuccess())
199 $result->addErrors($r->getErrors());
218 $dbRes = static::getList(
220 "filter" => array(
"=ORDER_ID" => $idOrder),
221 "select" => array(
"ID")
225 while ($entity = $dbRes->fetch())
227 $r = static::deleteInternal($entity[
'ID']);
228 if (!$r->isSuccess())
230 $result->addErrors($r->getErrors());
243 return TradingPlatform\OrderTable::delete($primary);
252 public function createClone(\SplObjectStorage $cloneEntity)
254 if ($this->
isClone() && $cloneEntity->contains($this))
256 return $cloneEntity[$this];
260 $tradeBindingCollection = parent::createClone($cloneEntity);
264 if ($cloneEntity->contains($this->order))
266 $tradeBindingCollection->order = $cloneEntity[
$this->order];
270 return $tradeBindingCollection;
294 foreach ($this->collection as $item)
296 $tradingPlatform = $item->getTradePlatform();
297 if (!$tradingPlatform || $tradingPlatform::TRADING_PLATFORM_CODE !== $platformCode)
302 if (!is_null($type) && !$tradingPlatform->isOfType($type))
307 return $tradingPlatform;
317 foreach ($this->collection as $item)
319 $result[] = $item->getField(
'TRADING_PLATFORM_ID');