/** * @return mixed * @throws \Exception */ public function setDataToObject() { if (!$this->isExistOrderEntityObject($this->data['orderOuterId'])) { throw new \Exception('Missing orderOuterId!'); } if (!$this->isExistProductEntityObject($this->data['productOuterId'])) { throw new \Exception('Missing productOuterId!'); } /** @var Order $order */ $order = $this->getObjectFromOrderEntityCollectionByOuterId($this->data['orderOuterId']); /** @var Product $product */ $product = $this->getObjectFromProductEntityCollectionByOuterId($this->data['productOuterId']); $this->object->setOrderOuterId($this->getFormattedData('orderOuterId', 'string')); $this->object->setProductOuterId($this->getFormattedData('productOuterId', 'string')); $this->object->setQuantity($this->getFormattedData('quantity', 'integer')); $this->object->setTotal($this->getFormattedData('total', 'integer')); $this->object->setOrderDate($this->getFormattedData('orderDate', 'date')); $this->object->setOrder($order); $this->object->setProduct($product); $order->addOrderProduct($this->object); $product->addProductOrder($this->object); $this->entityManager->persist($order); $this->entityManager->persist($product); parent::setDataToObject(); }