/** * @param StatusInterface $status * * @return bool */ public function hasStatusedElement(StatusInterface $status) { $role = $this->findOneBy(array('fromStatus.$id' => new \MongoId($status->getId()))); if ($role instanceof RoleInterface) { return true; } $role = $this->findOneBy(array('toStatus.$id' => new \MongoId($status->getId()))); return $role instanceof RoleInterface; }
/** * @param StatusableInterface $document * @param StatusInterface $toStatus * * @return bool */ public function isGranted(StatusableInterface $document, StatusInterface $toStatus) { $fromStatus = $document->getStatus(); if ($fromStatus->getId() != $toStatus->getId()) { $role = $this->roleRepository->findOneByFromStatusAndToStatus($fromStatus, $toStatus); $workflowFunctions = $this->workflowFunctionRepository->findByRole($role); foreach ($workflowFunctions as $workflowFunction) { if ($this->authorizationChecker->isGranted($workflowFunction->getId(), $document)) { return true; } } return false; } return true; }
/** * @param string|\Symfony\Component\Form\FormTypeInterface $type * @param null $data * @param array $options * @param string|null $editionRole * @param StatusInterface|null $status * * @return \Symfony\Component\Form\Form */ public function createForm($type, $data = null, array $options = array(), $editionRole = null, StatusInterface $status = null) { if (null !== $status && $status->isBlockedEdition()) { $options['disabled'] = true; } return parent::createForm($type, $data, $options, $editionRole); }
/** * @param StatusInterface $status */ public function __construct(StatusInterface $status) { parent::__construct(); $this->id = $status->getId(); $this->setName($status->getName()); $this->setPublished($status->isPublished()); $this->setInitial($status->isInitial()); $this->setDisplayColor($status->getDisplayColor()); $this->setLabels($status->getLabels()); $this->setBlockedEdition($status->isBlockedEdition()); $this->setOutOfWorkflow($status->isOutOfWorkflow()); foreach ($status->getToRoles() as $toRole) { $this->addToRole($toRole); } foreach ($status->getFromRoles() as $fromRole) { $this->addFromRole($fromRole); } }
/** * @param StatusInterface $fromStatus */ public function setFromStatus(StatusInterface $fromStatus) { $this->fromStatus = $fromStatus; $fromStatus->addFromRole($this); }
/** * Find all nodes (in all versions and all langauges) ready to be auto-unpublished * * @param string $siteId * @param StatusInterface $publishedStatus * * @return array */ public function findNodeToAutoUnpublish($siteId, StatusInterface $publishedStatus) { $date = new \Mongodate(strtotime(date('d F Y'))); $statusId = new \MongoId($publishedStatus->getId()); $qa = $this->createAggregationQuery(); $filter = array('siteId' => $siteId, 'deleted' => false, 'status._id' => $statusId, 'unpublishDate' => array('$lte' => $date)); $qa->match($filter); $qa->sort(array('version' => 1)); return $this->hydrateAggregateQuery($qa); }
/** * @param string $message * @param StatusInterface $status */ protected function sendLog($message, StatusInterface $status) { $this->logger->info($message, array('status_name' => $status->getName())); }
/** * @param StatusInterface $status * @param StatusableInterface|null $document * * @return FacadeInterface * * @throws TransformerParameterTypeException */ public function transform($status, $document = null) { if (!$status instanceof StatusInterface) { throw new TransformerParameterTypeException(); } $facade = $this->newFacade(); $facade->published = $status->isPublished(); $facade->initial = $status->isInitial(); $facade->autoPublishFrom = $status->isAutoPublishFrom(); $facade->autoUnpublishTo = $status->isAutoUnpublishTo(); $facade->name = $status->getName(); $facade->label = $this->multiLanguagesChoiceManager->choose($status->getLabels()); $facade->displayColor = $this->translator->trans('open_orchestra_backoffice.form.status.color.' . $status->getDisplayColor()); $facade->codeColor = $status->getDisplayColor(); $facade->id = $status->getId(); $facade->allowed = false; if ($document) { $facade->allowed = $this->authorizeStatusChangeManager->isGranted($document, $status); } if ($this->hasGroup(CMSGroupContext::STATUS_LINKS)) { $toRoles = array(); foreach ($status->getToRoles() as $toRole) { $toRoles[] = $toRole->getName(); } $facade->toRole = implode(',', $toRoles); $fromRoles = array(); foreach ($status->getFromRoles() as $fromRole) { $fromRoles[] = $fromRole->getName(); } $facade->fromRole = implode(',', $fromRoles); if ($this->authorizationChecker->isGranted(AdministrationPanelStrategy::ROLE_ACCESS_DELETE_STATUS, $status) && !$this->usageFinder->hasUsage($status)) { $facade->addLink('_self_delete', $this->generateRoute('open_orchestra_api_status_delete', array('statusId' => $status->getId()))); } if ($this->authorizationChecker->isGranted(AdministrationPanelStrategy::ROLE_ACCESS_UPDATE_STATUS)) { $facade->addLink('_self_form', $this->generateRoute('open_orchestra_backoffice_status_form', array('statusId' => $status->getId()))); } } return $facade; }
/** * @param StatusInterface $status * * @return bool */ public function hasStatusedElement(StatusInterface $status) { $qa = $this->createAggregationQuery(); $qa->match(array('status._id' => new \MongoId($status->getId()))); $content = $this->singleHydrateAggregateQuery($qa); return $content instanceof ContentInterface; }
/** * change Node status * * @param string $nodeId * @param StatusInterface $status * @param int $redirectionNumber * @param int $routeNumber */ protected function changeNodeStatusWithRouteRedirectionTest($nodeId, StatusInterface $status, $redirectionNumber, $routeNumber) { $this->client->request('POST', '/api/node/' . $nodeId . '/update', array(), array(), array(), '{"status_id": "' . $status->getId() . '"}'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertSame('application/json', $this->client->getResponse()->headers->get('content-type')); $this->assertEquals($redirectionNumber, count($this->redirectionRepository->findAll())); $this->assertEquals($routeNumber, count($this->routeDocumentRepository->findAll())); }