コード例 #1
0
 /**
  * @param ThemeInterface $theme
  *
  * @return FacadeInterface
  *
  * @throws TransformerParameterTypeException
  */
 public function transform($theme)
 {
     if (!$theme instanceof ThemeInterface) {
         throw new TransformerParameterTypeException();
     }
     $facade = $this->newFacade();
     $facade->id = $theme->getId();
     $facade->name = $theme->getName();
     if ($this->hasGroup(CMSGroupContext::THEME_LINKS)) {
         if ($this->authorizationChecker->isGranted(AdministrationPanelStrategy::ROLE_ACCESS_THEME)) {
             $facade->addLink('_self', $this->generateRoute('open_orchestra_api_theme_show', array('themeId' => $theme->getId())));
         }
         if ($this->authorizationChecker->isGranted(AdministrationPanelStrategy::ROLE_ACCESS_DELETE_THEME)) {
             $facade->addLink('_self_delete', $this->generateRoute('open_orchestra_api_theme_delete', array('themeId' => $theme->getId())));
         }
         if ($this->authorizationChecker->isGranted(AdministrationPanelStrategy::ROLE_ACCESS_UPDATE_THEME)) {
             $facade->addLink('_self_form', $this->generateRoute('open_orchestra_backoffice_theme_form', array('themeId' => $theme->getId())));
         }
     }
     return $facade;
 }