Beispiel #1
0
 public function reverseConvert($object)
 {
     if ($object instanceof Group) {
         if ($object->getAccount() == $this->accountManager->getCurrentAccount()) {
             return ['id' => $object->getId(), 'name' => $object->getName(), 'roles' => $object->getRoles()];
         }
     }
     return null;
 }
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $request = $event->getRequest();
     $host = $this->accountManager->getHostFromDomain($request->getHost());
     $account = $this->em->getRepository('CoreBundle:Account')->findOneBy(array('domain' => $host));
     if ($account instanceof AccountInterface) {
         $this->accountManager->setCurrentAccount($account);
     } else {
         $response = new JsonResponse(['error' => 'Account for ' . $request->getHost() . ' not found'], Response::HTTP_NOT_FOUND);
         $event->setResponse($response);
     }
 }
 protected function find($class, Request $request, $options, $name)
 {
     if ($options['mapping'] || $options['exclude']) {
         return false;
     }
     $id = $this->getIdentifier($request, $options, $name);
     if (false === $id || null === $id) {
         return false;
     }
     $criteria = array('id' => $id, 'account' => $this->accountManager->getCurrentAccount());
     try {
         return $this->getManager($options['entity_manager'], $class)->getRepository($class)->findOneBy($criteria);
     } catch (NoResultException $e) {
         return null;
     }
 }
 public function onNewCaller(CallbackEvent $event)
 {
     $callEvent = $event->getCallEvent();
     /** @var Call $call */
     $call = $callEvent->getCall();
     // Prepare new client information
     $client = $call->getClient();
     $client->setFirstName('from call center');
     if ($callEvent->getTreeName() || $callEvent->getTreeNumber()) {
         $condition = new ChannelCondition();
         $condition->setAccount($this->accountManager->getCurrentAccount());
         $condition->setTreeName($callEvent->getTreeName())->setTreeNumber($callEvent->getTreeNumber());
         $channel = $this->channelManager->searchOne($condition);
         if ($channel instanceof Channel) {
             $call->getClient()->setChannel($channel);
         }
     }
 }
 public function onFirstCall(CallbackEvent $event)
 {
     $callEvent = $event->getCallEvent();
     /** @var Call $call */
     $call = $callEvent->getCall();
     $callerSystem = $this->callManager->getCallerSystem($callEvent);
     $activity = $this->activityManager->create();
     $activity->setType('call');
     $this->activityManager->update($activity, false);
     $call->setActivity($activity);
     unset($activity);
     $call->setAccount($this->accountManager->getCurrentAccount());
     $user = $callerSystem->searchSourceUser($callEvent);
     if ($user instanceof UserInterface) {
         $call->setDirection(CallInterface::DIRECTION_OUTBOUND);
         $call->setUser($user);
         // Dispatch PerficoSipuniEvents::CALL when using SIP system for outbound call
         if ($callerSystem instanceof SipManager) {
             $e = new CallbackEvent();
             $e->setCallEvent($callEvent);
             $this->dispatcher->dispatch(PerficoSipuniEvents::CALL, $e);
         }
     } else {
         $call->setDirection(CallInterface::DIRECTION_INCOMING);
         $client = $callerSystem->searchSourceClient($callEvent);
         if ($client instanceof ClientInterface) {
             $call->setClient($client);
         } else {
             if ($callerSystem instanceof PhoneManager) {
                 // TODO need remove this condition since clients can call from Skype or Sip
                 $client = $this->clientManager->create();
                 $this->clientManager->update($client, false);
                 $callerSystem->prepareNewClient($client, $callEvent->getSrcNumber());
                 $call->setClient($client);
                 $e = new CallbackEvent();
                 $e->setCallEvent($callEvent);
                 $this->dispatcher->dispatch(PerficoCRMEvents::NEW_THE_CALLER, $e);
             }
         }
     }
 }
Beispiel #6
0
 /**
  * @return AccountInterface
  */
 public function getCurrentAccount()
 {
     return $this->accountManager->getCurrentAccount();
 }