public function insertUserGroupAction()
 {
     /** @var \rmatil\cms\Entities\UserGroup $userGroup */
     $userGroup = $this->app->serializer->deserialize($this->app->request->getBody(), EntityNames::USER_GROUP, 'json');
     try {
         $userGroup = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::USER_GROUP)->insert($userGroup);
     } catch (EntityInvalidException $eie) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $eie->getMessage());
         return;
     }
     ResponseFactory::createJsonResponse($this->app, $userGroup);
 }
 public function insertFileAction()
 {
     $file = new File();
     $file->setDescription($this->app->request->post('description'));
     try {
         $file = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::FILE)->insert($file);
     } catch (EntityNotInsertedException $enie) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $enie->getMessage());
         return;
     }
     ResponseFactory::createJsonResponse($this->app, $file);
 }
 public function updateSettingsAction($id)
 {
     /** @var \rmatil\cms\Entities\Setting $setting */
     $setting = $this->app->serializer->deserialize($this->app->request->getBody(), EntityNames::SETTING, 'json');
     try {
         $setting = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::SETTING)->update($setting);
     } catch (EntityNotFoundException $enfe) {
         ResponseFactory::createNotFoundResponse($this->app, $enfe->getMessage());
         return;
     } catch (EntityNotUpdatedException $enue) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $enue->getMessage());
         return;
     }
     ResponseFactory::createJsonResponse($this->app, $setting);
 }
 public function updateRepeatOptionAction($repeatOptionId)
 {
     /** @var \rmatil\cms\Entities\RepeatOption $repeatOption */
     $repeatOption = $this->app->serializer->deserialize($this->app->request->getBody(), EntityNames::REPEAT_OPTION, 'json');
     $repeatOption->setId($repeatOptionId);
     try {
         $repeatOption = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::REPEAT_OPTION)->update($repeatOption);
     } catch (EntityNotFoundException $enfe) {
         ResponseFactory::createNotFoundResponse($this->app, $enfe->getMessage());
         return;
     } catch (EntityNotUpdatedException $enue) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $enue->getMessage());
         return;
     }
     ResponseFactory::createJsonResponse($this->app, $repeatOption);
 }
 public function updateArticleCategoryAction($articleCategoryId)
 {
     /** @var \rmatil\cms\Entities\ArticleCategory $articleCategory */
     $articleCategory = $this->app->serializer->deserialize($this->app->request->getBody(), EntityNames::ARTICLE_CATEGORY, 'json');
     $articleCategory->setId($articleCategoryId);
     try {
         $obj = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::ARTICLE_CATEGORY)->update($articleCategory);
     } catch (EntityInvalidException $eie) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::BAD_REQUEST, $eie->getMessage());
         return;
     } catch (EntityNotFoundException $enfe) {
         ResponseFactory::createNotFoundResponse($this->app, $enfe->getMessage());
         return;
     } catch (EntityNotUpdatedException $enue) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $enue->getMessage());
         return;
     }
     ResponseFactory::createJsonResponse($this->app, $obj);
 }
 public function updateLanguageAction($languageId)
 {
     /** @var \rmatil\cms\Entities\Language $language */
     $language = $this->app->serializer->deserialize($this->app->request->getBody(), EntityNames::LANGUAGE, 'json');
     $language->setId($languageId);
     try {
         $language = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::LANGUAGE)->update($language);
     } catch (EntityInvalidException $eie) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::BAD_REQUEST, $eie->getMessage());
         return;
     } catch (EntityNotFoundException $enfe) {
         ResponseFactory::createNotFoundResponse($this->app, $enfe->getMessage());
         return;
     } catch (EntityNotUpdatedException $enue) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $enue->getMessage());
         return;
     }
     ResponseFactory::createJsonResponse($this->app, $language);
 }
 public function getEmptyArticleAction()
 {
     $article = new Article();
     $article->setAuthor($this->app->entityManager->getRepository(EntityNames::USER)->find($_SESSION['user_id']));
     $now = new DateTime('now', new DateTimeZone('UTC'));
     $article->setCreationDate($now);
     $article->setLastEditDate($now);
     ResponseFactory::createJsonResponse($this->app, $article);
 }
 public function getEmptyUserAction()
 {
     $userGroup = $this->app->entityManager->getRepository(EntityNames::USER_GROUP)->findOneBy(array('name' => 'ROLE_USER'));
     $user = new User();
     $user->setUserGroup($userGroup);
     ResponseFactory::createJsonResponse($this->app, $user);
 }
 public function getEmptyPageAction()
 {
     $page = new Page();
     $userRepository = $this->app->entityManager->getRepository(EntityNames::USER);
     $origUser = $userRepository->findOneBy(array('id' => $_SESSION['user_id']));
     $page->setAuthor($origUser);
     $now = new DateTime();
     $page->setCreationDate($now);
     $page->setLastEditDate($now);
     ResponseFactory::createJsonResponse($this->app, $page);
 }