コード例 #1
0
 /**
  * @param MailboxSaved $event
  */
 public function onMailboxSave(MailboxSaved $event)
 {
     $processSetings = $event->getMailbox()->getProcessSettings();
     if (!$processSetings instanceof CaseMailboxProcessSettings) {
         return;
     }
     $this->tagManager->saveTagging($processSetings);
 }
コード例 #2
0
 protected function onSuccess(User $user)
 {
     $this->manager->updateUser($user);
     $this->tagManager->saveTagging($user);
     // Reloads the user to reset its username. This is needed when the
     // username or password have been changed to avoid issues with the
     // security layer.
     $this->manager->reloadUser($user);
 }
コード例 #3
0
ファイル: ContactHandler.php プロジェクト: antrampa/crm
 /**
  * "Success" form handler
  *
  * @param Contact $entity
  * @param array $appendAccounts
  * @param array $removeAccounts
  */
 protected function onSuccess(Contact $entity, array $appendAccounts, array $removeAccounts)
 {
     $this->appendAccounts($entity, $appendAccounts);
     $this->removeAccounts($entity, $removeAccounts);
     $this->manager->persist($entity);
     $this->setUpdatedAt($entity);
     $this->manager->flush();
     $this->tagManager->saveTagging($entity);
 }
コード例 #4
0
ファイル: CaseEntityHandler.php プロジェクト: antrampa/crm
 /**
  * {@inheritdoc}
  */
 protected function onSuccess($entity)
 {
     $this->entityManager->persist($entity);
     $this->dispatcher->dispatch(Events::BEFORE_SAVE, new FormHandlerEvent($this->form, $entity));
     $this->entityManager->flush();
     if ($this->tagManager) {
         $this->tagManager->saveTagging($entity);
     }
 }
コード例 #5
0
ファイル: MergeListener.php プロジェクト: startupz/platform-1
 /**
  * Save tags
  *
  * @param EntityDataEvent $event
  */
 public function afterMergeEntity(EntityDataEvent $event)
 {
     $entityData = $event->getEntityData();
     $entityMetadata = $entityData->getMetadata();
     if (!$this->isTaggable($entityMetadata)) {
         return;
     }
     $entity = $entityData->getMasterEntity();
     $this->tagManager->saveTagging($entity);
 }
コード例 #6
0
ファイル: CopyTagging.php プロジェクト: snorchel/platform
 /**
  * {@inheritdoc}
  */
 protected function executeAction($context)
 {
     $source = $this->getTaggable($context, static::PATH_SOURCE);
     $destination = $this->getTaggable($context, static::PATH_DESTINATION);
     $organization = $this->getOrganization($context);
     $this->tagManager->loadTagging($source, $organization);
     $tags = $this->tagManager->getTags($source);
     $this->tagManager->setTags($destination, $tags);
     $this->tagManager->saveTagging($destination, true, $organization);
 }
コード例 #7
0
ファイル: CopyTagging.php プロジェクト: 2ndkauboy/platform
 /**
  * {@inheritdoc}
  */
 protected function executeAction($context)
 {
     $source = $this->getObject($context, static::PATH_SOURCE);
     $destination = $this->getObject($context, static::PATH_DESTINATION);
     $this->tagManager->loadTagging($source);
     $tags = $source->getTags();
     $preparedTags = ['all' => $tags->toArray(), 'owner' => $tags->toArray()];
     $destination->setTags($preparedTags);
     $this->tagManager->saveTagging($destination);
 }
コード例 #8
0
ファイル: MergeListener.php プロジェクト: Maksold/platform
 /**
  * Save tags
  *
  * @param EntityDataEvent $event
  */
 public function afterMergeEntity(EntityDataEvent $event)
 {
     $entityData = $event->getEntityData();
     $entityMetadata = $entityData->getMetadata();
     if (!$this->isTaggable($entityMetadata)) {
         return;
     }
     $masterEntity = $entityData->getMasterEntity();
     $masterTags = $this->tagManager->getTags($masterEntity)->getValues();
     $this->tagManager->setTags($masterEntity, ['all' => $masterTags, 'owner' => $masterTags]);
     $this->tagManager->saveTagging($masterEntity);
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 protected function onSuccess($entity)
 {
     $targetEntity = $entity['target'];
     /** @var ArrayCollection $tags */
     $tags = $entity['tags'];
     $names = array_map(function ($tag) {
         return $tag['name'];
     }, $tags->getValues());
     $tags = $this->tagManager->loadOrCreateTags($names);
     $this->tagManager->setTags($targetEntity, new ArrayCollection($tags));
     $this->tagManager->saveTagging($targetEntity);
 }
コード例 #10
0
 /**
  * Update Branch
  *
  * @param Command\BranchCommand $branchCommand
  * @return int
  */
 public function updateBranch(Command\BranchCommand $branchCommand)
 {
     $this->isGranted('EDIT', 'Entity:DiamanteDeskBundle:Branch');
     /**
      * @var $branch \Diamante\DeskBundle\Model\Branch\Branch
      */
     $branch = $this->branchRepository->get($branchCommand->id);
     if ($branchCommand->defaultAssignee) {
         $assignee = $this->userService->getByUser(new User($branchCommand->defaultAssignee, User::TYPE_ORO));
     } else {
         $assignee = null;
     }
     /** @var \Symfony\Component\HttpFoundation\File\File $file */
     $file = null;
     if ($branchCommand->isRemoveLogo()) {
         $this->branchLogoHandler->remove($branch->getLogo());
         $file = new Logo();
     } elseif ($branchCommand->logoFile) {
         if ($branch->getLogo()) {
             $this->branchLogoHandler->remove($branch->getLogo());
         }
         $logo = $this->handleLogoUpload($branchCommand->logoFile);
         $file = new Logo($logo->getFilename(), $branchCommand->logoFile->getClientOriginalName());
     }
     $branch->update($branchCommand->name, $branchCommand->description, $assignee, $file);
     $this->branchRepository->store($branch);
     //TODO: Refactor tag manipulations.
     $this->tagManager->deleteTaggingByParams($branch->getTags(), get_class($branch), $branch->getId());
     $tags = $branchCommand->tags;
     $tags['owner'] = $tags['all'];
     $branch->setTags($tags);
     $this->tagManager->saveTagging($branch);
     return $branch->getId();
 }
コード例 #11
0
ファイル: UserHandler.php プロジェクト: antrampa/platform
 /**
  * {@inheritdoc}
  */
 protected function onSuccess(User $user)
 {
     $this->manager->updateUser($user);
     $this->tagManager->saveTagging($user);
     if ($this->form->has('inviteUser') && $this->form->has('plainPassword') && $this->form->get('inviteUser')->getViewData() && $this->form->get('plainPassword')->getViewData()) {
         try {
             $this->sendInviteMail($user, $this->form->get('plainPassword')->getViewData()['first']);
         } catch (\Exception $ex) {
             $this->logger->error('Invitation email sending failed.', ['exception' => $ex]);
             $this->flashBag->add('warning', $this->translator->trans('oro.user.controller.invite.fail.message'));
         }
     }
     // Reloads the user to reset its username. This is needed when the
     // username or password have been changed to avoid issues with the
     // security layer.
     // Additional checking for userConfigManager !== null is added because of API
     // to avoid "Call to a member function on a non-object".
     $this->manager->reloadUser($user);
     if ($this->form->has('signature') && $this->userConfigManager !== null) {
         $signature = $this->form->get('signature')->getData();
         if ($signature) {
             $this->userConfigManager->set('oro_email.signature', $signature);
         } else {
             $this->userConfigManager->reset('oro_email.signature');
         }
         $this->userConfigManager->flush();
     }
 }
コード例 #12
0
ファイル: LoadTagsData.php プロジェクト: mehulsbhatt/crm
 public function loadContactsTags()
 {
     $userTagsCount = count($this->tagsUser);
     $accountTagsCount = count($this->tagsAccount);
     foreach ($this->contactsRepository as $contact) {
         $this->tagManager->setTags($contact, new ArrayCollection([$this->tagsUser[rand(0, $userTagsCount - 1)], $this->tagsAccount[rand(0, $accountTagsCount - 1)]]));
         $this->tagManager->saveTagging($contact, false);
     }
     $this->flush($this->em);
 }
コード例 #13
0
 /**
  * Update Article
  *
  * @param Command\ArticleCommand $articleCommand
  * @return int
  */
 public function updateArticle(Command\ArticleCommand $articleCommand)
 {
     /** @var $article Article */
     $article = $this->repository->get($articleCommand->id);
     $article->update($articleCommand->title, $articleCommand->content, $articleCommand->status);
     $this->registry->getManager()->persist($article);
     $this->handleTagging($articleCommand, $article);
     $this->registry->getManager()->flush();
     $this->tagManager->saveTagging($article);
     return $article->getId();
 }
コード例 #14
0
ファイル: LoadTagsData.php プロジェクト: antrampa/crm
 public function loadContactsTags()
 {
     foreach ($this->contactsRepository as $contact) {
         $user = $this->usersRepository[rand(0, $this->randomUser)];
         $securityContext = $this->container->get('security.context');
         $token = new UsernamePasswordOrganizationToken($user, $user->getUsername(), 'main', $this->organization);
         $securityContext->setToken($token);
         $ownTags = array($this->tagsUser[rand(0, $this->randomUserTag)], $this->tagsAccount[rand(0, $this->randomAccountTag - 1)]);
         $contact->setTags(array('owner' => $ownTags, 'all' => array()));
         $this->persist($this->em, $contact);
         $this->tagManager->saveTagging($contact, false);
     }
     $this->flush($this->em);
     $this->em->clear('Oro\\Bundle\\ContactBundle\\Entity\\Contact');
 }
コード例 #15
0
ファイル: UserHandler.php プロジェクト: xamin123/platform
 /**
  * {@inheritdoc}
  */
 protected function onSuccess(User $user)
 {
     $this->manager->updateUser($user);
     $this->tagManager->saveTagging($user);
     if ($this->form->has('inviteUser') && $this->form->has('plainPassword') && $this->form->get('inviteUser')->getViewData() && $this->form->get('plainPassword')->getViewData()) {
         try {
             $this->sendInviteMail($user, $this->form->get('plainPassword')->getViewData()['first']);
         } catch (\Exception $ex) {
             $this->logger->error('Invitation email sending failed.', array('exception' => $ex));
             $this->flashBag->add('warning', $this->translator->trans('oro.user.controller.invite.fail.message'));
         }
     }
     // Reloads the user to reset its username. This is needed when the
     // username or password have been changed to avoid issues with the
     // security layer.
     $this->manager->reloadUser($user);
 }
コード例 #16
0
 /**
  * Update Branch
  *
  * @param Command\BranchCommand $branchCommand
  * @return int
  */
 public function updateBranch(Command\BranchCommand $branchCommand)
 {
     $this->isGranted('EDIT', 'Entity:DiamanteDeskBundle:Branch');
     /**
      * @var $branch \Diamante\DeskBundle\Entity\Branch
      */
     $branch = $this->branchRepository->get($branchCommand->id);
     $assignee = $this->extractDefaultBranchAssignee($branchCommand);
     if ($branchCommand->isRemoveLogo() || $branchCommand->logoFile) {
         $this->removeBranchLogo($branch);
     }
     $file = $this->uploadBranchLogoIfExists($branchCommand);
     $branch->update($branchCommand->name, $branchCommand->description, $assignee, $file);
     $this->registry->getManager()->persist($branch);
     $this->handleTagging($branchCommand, $branch);
     $this->registry->getManager()->flush();
     $this->tagManager->saveTagging($branch);
     return $branch->getId();
 }
コード例 #17
0
ファイル: LeadHandler.php プロジェクト: antrampa/crm
 /**
  * "Success" form handler
  *
  * @param Lead $entity
  */
 protected function onSuccess(Lead $entity)
 {
     $this->manager->persist($entity);
     $this->manager->flush();
     $this->tagManager->saveTagging($entity);
 }
コード例 #18
0
 /**
  * Update Ticket
  *
  * @param Command\UpdateTicketCommand $command
  * @return Ticket
  *
  * @throws \RuntimeException if unable to load required ticket and assignee
  */
 public function updateTicket(Command\UpdateTicketCommand $command)
 {
     \Assert\that($command->attachmentsInput)->nullOr()->all()->isInstanceOf('Diamante\\DeskBundle\\Api\\Dto\\AttachmentInput');
     $ticket = $this->loadTicketById($command->id);
     $this->isGranted('EDIT', $ticket);
     $reporter = $ticket->getReporter();
     if ((string) $command->reporter !== (string) $reporter) {
         $reporter = $command->reporter;
     }
     $assignee = null;
     if ($command->assignee) {
         $assignee = $ticket->getAssignee();
         $currentAssigneeId = empty($assignee) ? null : $assignee->getId();
         if ($command->assignee !== $currentAssigneeId) {
             $assignee = $this->oroUserRepository->find($command->assignee);
         }
     }
     $ticket->update($command->subject, $command->description, $reporter, new Priority($command->priority), new Status($command->status), new Source($command->source), $assignee, $command->tags);
     $this->createAttachments($command, $ticket);
     $this->doctrineRegistry->getManager()->persist($ticket);
     $this->doctrineRegistry->getManager()->flush();
     $this->tagManager->saveTagging($ticket);
     $ticket->setTags(null);
     $this->loadTagging($ticket);
     $this->dispatchWorkflowEvent($this->doctrineRegistry, $this->dispatcher, $ticket);
     return $ticket;
 }
コード例 #19
0
 /**
  * Update Ticket
  *
  * @param UpdateTicketCommand $command
  * @return \Diamante\DeskBundle\Model\Ticket\Ticket
  * @throws \RuntimeException if unable to load required ticket and assignee
  */
 public function updateTicket(UpdateTicketCommand $command)
 {
     \Assert\that($command->attachmentsInput)->nullOr()->all()->isInstanceOf('Diamante\\DeskBundle\\Api\\Dto\\AttachmentInput');
     $ticket = $this->loadTicketById($command->id);
     $this->isGranted('EDIT', $ticket);
     $reporter = $ticket->getReporter();
     if ((string) $command->reporter !== (string) $reporter) {
         $reporter = $command->reporter;
     }
     $assignee = null;
     if ($command->assignee) {
         $assignee = $ticket->getAssignee();
         $currentAssigneeId = empty($assignee) ? null : $assignee->getId();
         if ($command->assignee != $currentAssigneeId) {
             $assignee = $this->userService->getByUser(new User((int) $command->assignee, User::TYPE_ORO));
         }
     }
     $ticket->update($command->subject, $command->description, $reporter, new Priority($command->priority), new Status($command->status), new Source($command->source), $assignee);
     if (is_array($command->attachmentsInput) && false === empty($command->attachmentsInput)) {
         foreach ($command->attachmentsInput as $each) {
             $this->attachmentManager->createNewAttachment($each->getFilename(), $each->getContent(), $ticket);
         }
     }
     $this->ticketRepository->store($ticket);
     $this->tagManager->deleteTaggingByParams($ticket->getTags(), get_class($ticket), $ticket->getId());
     $tags = $command->tags;
     $tags['owner'] = $tags['all'];
     $ticket->setTags($tags);
     $this->tagManager->saveTagging($ticket);
     $this->dispatchEvents($ticket);
     return $ticket;
 }