Ejemplo n.º 1
0
 /**
  * @covers Jobs\Options\ProviderOptions::addChannel
  * @covers Jobs\Options\ProviderOptions::getChannel
  */
 public function testAddGetChannel()
 {
     $channel = new ChannelOptions();
     $channel->setKey('test')->setLabel('label');
     $this->options->addChannel($channel);
     $this->assertEquals($channel, $this->options->getChannel('test'));
     $this->assertEquals([], $this->options->getChannel('nonexistance'));
 }
Ejemplo n.º 2
0
 public function __invoke(JobEvent $event)
 {
     $job = $event->getJobEntity();
     $invoiceAddressDraft = $this->draftRepository->findByJobId($job->getId());
     $invoiceAddress = $invoiceAddressDraft->getInvoiceAddress();
     $snapshotBuilder = new Builder();
     $snapshot = $snapshotBuilder->build($job);
     $products = new ArrayCollection();
     foreach ($job->getPortals() as $key) {
         $product = new Product();
         $channel = $this->providerOptions->getChannel($key);
         $product->setName($channel->getLabel())->setProductNumber($channel->getExternalKey())->setQuantity(1);
         $products->add($product);
     }
     $data = ['type' => OrderInterface::TYPE_JOB, 'taxRate' => $this->options->getTaxRate(), 'price' => $this->priceFilter->filter($job->getPortals()), 'invoiceAddress' => $invoiceAddress, 'currency' => $this->options->getCurrency(), 'currencySymbol' => $this->options->getCurrencySymbol(), 'entity' => $snapshot, 'products' => $products];
     $order = $this->orderRepository->create($data);
     $this->orderRepository->store($order);
     $this->draftRepository->remove($invoiceAddressDraft);
 }