Esempio n. 1
0
 public function onCreate(OrderEvent $event)
 {
     $params = ['usr_id' => $event->getOrder()->getUser()->getId(), 'order_id' => $event->getOrder()->getId()];
     $base_ids = array_unique(array_map(function (OrderElement $element) {
         return $element->getBaseId();
     }, iterator_to_array($event->getOrder()->getElements())));
     $query = $this->app['phraseanet.user-query'];
     $users = $query->on_base_ids($base_ids)->who_have_right(['order_master'])->execute()->get_results();
     if (count($users) == 0) {
         return;
     }
     $datas = json_encode($params);
     $orderInitiator = $event->getOrder()->getUser();
     foreach ($users as $user) {
         $mailed = false;
         if ($this->shouldSendNotificationFor($user, 'eventsmanager_notify_order')) {
             try {
                 $receiver = Receiver::fromUser($user);
             } catch (\Exception $e) {
                 continue;
             }
             $mail = MailInfoNewOrder::create($this->app, $receiver);
             $mail->setUser($orderInitiator);
             $this->app['notification.deliverer']->deliver($mail);
             $mailed = true;
         }
         $this->app['events-manager']->notify($user->getId(), 'eventsmanager_notify_order', $datas, $mailed);
     }
 }
 public function __construct(Order $order, User $admin, $quantity)
 {
     parent::__construct($order);
     $this->admin = $admin;
     $this->quantity = $quantity;
 }