private function createEnvironment($name, $color, $managed)
 {
     $environment = new Environment();
     $environment->setName($name);
     $environment->setColor($color);
     $environment->setManaged($managed);
     return $environment;
 }
 public function findAvailableEnvironements(Environment $defaultEnv)
 {
     /** @var QueryBuilder $qb */
     $qb = $this->createQueryBuilder('e');
     $qb->where($qb->expr()->neq('e.id', ':defaultEnvId'));
     $qb->andWhere('e.managed <> 0');
     $qb->orderBy('e.name', 'ASC');
     $qb->setParameter('defaultEnvId', $defaultEnv->getId());
     return $qb->getQuery()->getResult();
 }
 public function __construct(Environment $environment)
 {
     $this->environment = $environment;
     $message = "The User has no circle to manipulate the object in the environment " . $environment->getName();
     parent::__construct($message, 0, null);
 }
 /**
  * Go throw all objects defined for a specfic environement and republish them into the index correspond to the environment.
  * 
  * @param Environment $environment
  * @param unknown $alias
  */
 private function reindexAll(Environment $environment, $alias)
 {
     /** @var  Client $client */
     $client = $this->get('app.elasticsearch');
     /** @var \AppBundle\Entity\Revision $revision */
     foreach ($environment->getRevisions() as $revision) {
         if (!$revision->getDeleted()) {
             $objectArray = $this->get('ems.service.mapping')->dataFieldToArray($revision->getDataField());
             $status = $client->index(['index' => $alias, 'id' => $revision->getOuuid(), 'type' => $revision->getContentType()->getName(), 'body' => $objectArray]);
         }
     }
     $this->addFlash('notice', count($environment->getRevisions()) . ' objects have been reindexed in ' . $alias);
 }
Beispiel #5
0
 public function unpublish(Revision $revision, Environment $environment)
 {
     if (!$this->authorizationChecker->isGranted($revision->getContentType()->getEditRole())) {
         $this->session->getFlashBag()->add('warning', 'You are not allowed to unpublish the object ' . $revision);
         return;
     }
     $user = $this->userService->getCurrentUser();
     if (!empty($environment->getCircles() && !$this->authorizationChecker->isGranted('ROLE_ADMIN') && empty(array_intersect($environment->getCircles(), $user->getCircles())))) {
         $this->session->getFlashBag()->add('warning', 'You are not allowed to unpublish from the environment ' . $environment);
         return;
     }
     if ($revision->getContentType()->getEnvironment() == $environment) {
         $this->session->getFlashBag()->add('warning', 'You can\'t unpublish from the default environment of the content type ' . $revision->getContentType());
         return;
     }
     $this->dataService->lockRevision($revision, $environment);
     $revision->removeEnvironment($environment);
     try {
         $status = $this->client->delete(['id' => $revision->getOuuid(), 'index' => $environment->getAlias(), 'type' => $revision->getContentType()->getName()]);
         $this->session->getFlashBag()->add('notice', 'The object ' . $revision . ' has been unpublished from environment ' . $environment->getName());
     } catch (\Exception $e) {
         if (!$revision->getDeleted()) {
             $this->session->getFlashBag()->add('warning', 'The object ' . $revision . ' was already unpublished from environment ' . $environment->getName());
         }
     }
     $em = $this->doctrine->getManager();
     $em->persist($revision);
     $em->flush();
     $this->auditService->auditLog('PublishService:unpublish', $revision->getRawData(), $environment->getName());
 }
 public function findByOuuidAndContentTypeAndEnvironnement(ContentType $contentType, $ouuid, Environment $env)
 {
     $qb = $this->createQueryBuilder('r');
     $qb->join('r.environments', 'e');
     $qb->where('r.ouuid = :ouuid and e.id = :envId and r.contentType = :contentTypeId');
     $qb->setParameters(['ouuid' => $ouuid, 'envId' => $env->getId(), 'contentTypeId' => $contentType->getId()]);
     return $qb->getQuery()->getResult();
 }