/**
  * @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          $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;
 }