/** * Updates or creates new StyleMap * @Route("save") * @Method("POST") * * @param Request $request * @return Response */ public function save(Request $request) { if ($this->securityContext->isUserAllowedToEdit($this->user)) { $styles = $request->request->all(); $styleMap = $this->styleManager->saveArray($styles); return $this->getSuccessMessage($styleMap); } return $this->getErrorMessage("Update : Current user is not authorized to access style with id " . $request->get("id"), HTTPStatusConstants::_UNAUTHORIZED); }
/** * @param string $styleMapId * @param string $styleId * @return bool * @throws \Symfony\Component\Config\Definition\Exception\Exception */ public function removeStyle($styleMapId, $styleId) { $styleMap = $this->getById($styleMapId); if ($styleMap) { $style = $this->styleManager->getById($styleId); if (!$style) { throw new Exception('Der Style kann nicht gelöscht werden. Er gehört nicht zu der Stylemap.'); } $style->removeStyleMapById($styleMapId); $styleMap->removeStyleById($styleId); $this->styleManager->save($style); return $this->save($styleMap) ? true : false; } return false; }
/** * @return Style */ public function getMockupStyle() { return $this->styleManager->create($this->styleData); }