public function insertArticleCategoryAction()
 {
     $articleCategory = $this->app->serializer->deserialize($this->app->request->getBody(), EntityNames::ARTICLE_CATEGORY, 'json');
     try {
         $articleCategory = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::ARTICLE_CATEGORY)->insert($articleCategory);
     } catch (EntityNotInsertedException $enie) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $enie->getMessage());
         return;
     }
     ResponseFactory::createJsonResponseWithCode($this->app, HttpStatusCodes::CREATED, $articleCategory);
 }
 public function insertLanguageAction()
 {
     /** @var \rmatil\cms\Entities\Language $language */
     $language = $this->app->serializer->deserialize($this->app->request->getBody(), EntityNames::LANGUAGE, 'json');
     try {
         $language = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::LANGUAGE)->insert($language);
     } catch (EntityNotInsertedException $enie) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $enie->getMessage());
     }
     ResponseFactory::createJsonResponseWithCode($this->app, HttpStatusCodes::CREATED, $language);
 }
 public function insertRepeatOptionAction()
 {
     /** @var \rmatil\cms\Entities\RepeatOption $repeatOption */
     $repeatOption = $this->app->serializer->deserialize($this->app->request->getBody(), EntityNames::REPEAT_OPTION, 'json');
     try {
         $repeatOption = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::REPEAT_OPTION)->insert($repeatOption);
     } catch (EntityNotInsertedException $enie) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $enie->getMessage());
         return;
     }
     ResponseFactory::createJsonResponseWithCode($this->app, HttpStatusCodes::CREATED, $repeatOption);
 }
 public function insertPageCategoryAction()
 {
     /** @var \rmatil\cms\Entities\PageCategory $pageCategory */
     $pageCategory = $this->app->serializer->deserialize($this->app->request->getBody(), EntityNames::PAGE_CATEGORY, 'json');
     try {
         $pageCategory = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::PAGE_CATEGORY)->insert($pageCategory);
     } catch (EntityNotInsertedException $enie) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $enie->getMessage());
         return;
     }
     ResponseFactory::createJsonResponseWithCode($this->app, HttpStatusCodes::CREATED, $pageCategory);
 }
 public function insertArticleAction()
 {
     /** @var \rmatil\cms\Entities\Article $articleObject */
     $articleObject = $this->app->serializer->deserialize($this->app->request->getBody(), EntityNames::ARTICLE, 'json');
     $articleObject->setAuthor($this->app->entityManager->getRepository(EntityNames::USER)->find($_SESSION['user_id']));
     try {
         $article = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::ARTICLE)->insert($articleObject);
     } catch (EntityNotInsertedException $enie) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $enie->getMessage());
         return;
     }
     ResponseFactory::createJsonResponseWithCode($this->app, HttpStatusCodes::CREATED, $article);
 }
 public function insertUserAction()
 {
     /** @var \rmatil\cms\Entities\User $user */
     $user = $this->app->serializer->deserialize($this->app->request->getBody(), EntityNames::USER, 'json');
     try {
         $user = $this->app->dataAccessorFactory->getDataAccessor(EntityNames::USER)->insert($user);
     } catch (EntityNotInsertedException $enie) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, $enie->getMessage());
         return;
     } catch (RegistrationMailNotSentException $rmnse) {
         ResponseFactory::createErrorJsonResponse($this->app, HttpStatusCodes::CONFLICT, sprintf('Could not sent registration email: %s', $rmnse->getMessage()));
         return;
     }
     ResponseFactory::createJsonResponseWithCode($this->app, HttpStatusCodes::CREATED, $user);
 }