'staff_2', 'requestData' => [ 'articleId' => [ 'validation' => DataValidator::dataStoreId('article'), 'error' => ERRORS::INVALID_TOPIC ], 'title' => [ 'validation' => DataValidator::OneOf( DataValidator::notBlank()->length(LengthConfig::MIN_LENGTH_NAME, LengthConfig::MAX_LENGTH_NAME), DataValidator::nullType() ), 'error' => ERRORS::INVALID_TITLE ], 'content' => [ 'validation' => DataValidator::oneOf( DataValidator::content(), DataValidator::nullType() ), 'error' => ERRORS::INVALID_CONTENT ] ] ]; } public function handler() { $topicId = Controller::request('topicId'); $content = Controller::request('content', true); $title = Controller::request('title'); $article = Article::getDataStore(Controller::request('articleId')); $createdArticleTookByTitle = Article::getDataStore($title, 'title'); $createdArticleTookByContent = Article::getDataStore($content, 'content'); if(!$createdArticleTookByTitle->isNull() && $article->title !== $createdArticleTookByTitle->title){ throw new RequestException(ERRORS::TITLE_ALREADY_USED); } if(!$createdArticleTookByContent->isNull() && $article->content !== $createdArticleTookByContent->content){ throw new RequestException(ERRORS::CONTENT_ALREADY_USED); } if ($topicId) { $newArticleTopic = Topic::getDataStore($topicId); if (!$newArticleTopic->isNull()) { $article->topic = $newArticleTopic; } else { throw new RequestException(ERRORS::INVALID_TOPIC); return; } } if($content) { $fileUploader = FileUploader::getInstance(); $fileUploader->setPermission(FileManager::PERMISSION_ARTICLE); $imagePaths = $this->uploadImages(true); $article->content = $this->replaceWithImagePaths($imagePaths, $content); } if($title) { $article->title = $title; } if(Controller::request('position')) { $article->position = Controller::request('position'); } $article->lastEdited = Date::getCurrentDate(); $article->store(); Log::createLog('EDIT_ARTICLE', $article->title); Response::respondSuccess(); } }