Ejemplo n.º 1
0
 /**
  * {@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);
 }
 /**
  * Retrieves Article by id
  * @param $id
  * @return Article
  */
 public function loadArticle($id)
 {
     /** @var Article $article */
     $article = $this->repository->get($id);
     if (is_null($article)) {
         throw new ArticleNotFoundException();
     }
     $this->tagManager->loadTagging($article, null);
     return $article;
 }
Ejemplo n.º 3
0
 /**
  * {@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);
 }
Ejemplo n.º 4
0
 /**
  * @param FormEvent $event
  */
 public function preSet(FormEvent $event)
 {
     $entity = $event->getForm()->getParent()->getData();
     if (!$this->taggableHelper->isTaggable($entity)) {
         return;
     }
     $this->tagManager->loadTagging($entity);
     $tags = $this->tagManager->getPreparedArray($entity, null, $this->organization);
     $event->setData($tags);
 }
Ejemplo n.º 5
0
 /**
  * Load tags
  *
  * @param EntityDataEvent $event
  */
 public function onCreateEntityData(EntityDataEvent $event)
 {
     $entityData = $event->getEntityData();
     $entityMetadata = $entityData->getMetadata();
     if (!$this->isTaggable($entityMetadata)) {
         return;
     }
     $entities = $entityData->getEntities();
     foreach ($entities as $entity) {
         $this->tagManager->loadTagging($entity);
     }
 }
 /**
  * Rendering tags depend on context..
  *
  * @param \Twig_Environment $twig
  * @param $entityId
  * @param $context
  * @return string
  */
 public function renderTag(\Twig_Environment $twig, $entityId, $context)
 {
     switch ($context) {
         case 'branch':
             /** @var \Diamante\DeskBundle\Entity\Branch $entity */
             $entity = $this->registry->getRepository('DiamanteDeskBundle:Branch')->get($entityId);
             break;
         case 'ticket':
             /** @var \Diamante\DeskBundle\Entity\Ticket $entity */
             $entity = $this->registry->getRepository('DiamanteDeskBundle:Ticket')->get($entityId);
             break;
         default:
             throw new \InvalidArgumentException('Entity didn\'t get.');
     }
     $this->tagManager->loadTagging($entity);
     return $twig->render('DiamanteDeskBundle:Tag/Datagrid/Property:tag.html.twig', ['tags' => $entity->getTags()->getValues()]);
 }
Ejemplo n.º 7
0
 public function testLoadTagging()
 {
     $resource = $this->getMockForAbstractClass('Oro\\Bundle\\TagBundle\\Entity\\Taggable');
     $repo = $this->getMockBuilder('Oro\\Bundle\\TagBundle\\Entity\\Repository\\TagRepository')->disableOriginalConstructor()->getMock();
     $repo->expects($this->once())->method('getTags')->will($this->returnValue(array(new Tag(self::TEST_TAG_NAME))));
     $this->em->expects($this->once())->method('getRepository')->with('Oro\\Bundle\\TagBundle\\Entity\\Tag')->will($this->returnValue($repo));
     $this->manager->loadTagging($resource);
 }
 /**
  * @param $tickets
  * @param TagManager $tagManager
  * @return mixed
  */
 public function afterResult($tickets, $tagManager)
 {
     foreach ($tickets as $ticket) {
         /** @var Ticket $ticket */
         $tagManager->loadTagging($ticket);
     }
     return $tickets;
 }
 /**
  * Retrieves Branch by id
  * @param $id
  * @return Branch
  */
 public function getBranch($id)
 {
     $this->isGranted('VIEW', 'Entity:DiamanteDeskBundle:Branch');
     $branch = $this->branchRepository->get($id);
     if (is_null($branch)) {
         throw new BranchNotFoundException();
     }
     $this->tagManager->loadTagging($branch);
     return $branch;
 }
 /**
  * Retrieves Branch by id
  * @param $id
  * @return Branch
  */
 public function getBranch($id)
 {
     $this->isGranted('VIEW', 'Entity:DiamanteDeskBundle:Branch');
     $branch = $this->branchRepository->get($id);
     if (is_null($branch)) {
         throw new \RuntimeException('Branch loading failed. Branch not found.');
     }
     $this->tagManager->loadTagging($branch);
     return $branch;
 }
 /**
  * Retrieves list of all Tickets. Performs filtering of tickets if provided with criteria as GET parameters.
  * Time filtering parameters as well as paging/sorting configuration parameters can be found in \Diamante\DeskBundle\Api\Command\Filter\CommonFilterCommand class.
  * Time filtering values should be converted to UTC
  *
  * @ApiDoc(
  *  description="Returns all tickets.",
  *  uri="/tickets.{_format}",
  *  method="GET",
  *  resource=true,
  *  statusCodes={
  *      200="Returned when successful",
  *      403="Returned when the user is not authorized to list tickets"
  *  }
  * )
  *
  * @param Command\Filter\FilterTicketsCommand $ticketFilterCommand
  * @return \Diamante\DeskBundle\Entity\Ticket[]
  */
 public function listAllTickets(Command\Filter\FilterTicketsCommand $ticketFilterCommand)
 {
     $criteriaProcessor = new TicketFilterCriteriaProcessor();
     $repository = $this->getTicketRepository();
     $user = $this->getAuthorizationService()->getLoggedUser();
     if ($user instanceof ApiUser) {
         $user = $this->userService->getUserFromApiUser($user);
     }
     $pagingProperties = $this->buildPagination($criteriaProcessor, $repository, $ticketFilterCommand, $this->apiPagingService);
     $criteria = $criteriaProcessor->getCriteria();
     $tickets = $repository->filter($criteria, $pagingProperties, $user);
     if ($this->loggedUser instanceof OroUser) {
         foreach ($tickets as $ticket) {
             /** @var Ticket $ticket */
             $this->tagManager->loadTagging($ticket);
         }
     }
     $pagingInfo = $this->apiPagingService->getPagingInfo($repository, $pagingProperties, $criteria);
     $this->populatePagingHeaders($this->apiPagingService, $pagingInfo);
     return $tickets;
 }
 /**
  * @param Ticket $ticket
  */
 private function loadTagging(Ticket $ticket)
 {
     if ($this->loggedUser instanceof OroUser) {
         $this->tagManager->loadTagging($ticket);
     }
 }
 public function renderTag(\Twig_Environment $twig, $ticketId)
 {
     $ticket = $this->ticketRepository->get($ticketId);
     $this->tagManager->loadTagging($ticket);
     return $twig->render('DiamanteDeskBundle:Ticket/Datagrid/Property:tag.html.twig', ['tags' => $ticket->getTags()->getValues()]);
 }
 /**
  * Load Ticket by given Ticket Key
  * @param string $key
  * @return \Diamante\DeskBundle\Model\Ticket\Ticket
  */
 public function loadTicketByKey($key)
 {
     $ticketHistory = $this->ticketHistoryRepository->findOneByTicketKey($key);
     if ($ticketHistory) {
         $ticket = $this->ticketRepository->get($ticketHistory->getTicketId());
         $currentKey = (string) $ticket->getKey();
         throw new TicketMovedException($currentKey);
     } else {
         $ticketKey = TicketKey::from($key);
         $ticket = $this->loadTicketByTicketKey($ticketKey);
     }
     if ($this->securityFacade->getOrganization()) {
         $this->tagManager->loadTagging($ticket);
     }
     $this->isGranted('VIEW', $ticket);
     return $ticket;
 }