public function __invoke(AdminControllerEvent $event)
 {
     $ordersCount = $this->orders->count();
     $draftsCount = $this->drafts->count();
     $data = ['Orders' => $ordersCount, 'Invoice address drafts' => $draftsCount];
     $event->addViewVariables('orders', ['data' => $data], -1);
 }
Example #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);
 }