Commit 3c34cae2 authored by Tino Goratsch's avatar Tino Goratsch

unified the `\ACP3\Core\Helper\Action::handleCreatePostAction()` and...

unified the `\ACP3\Core\Helper\Action::handleCreatePostAction()` and `\ACP3\Core\Helper\Action::handleEditPostAction()` methods into the new method `\ACP3\Core\Helper\Action::handleSaveAction()`
parent a90d8d18
......@@ -173,14 +173,12 @@ class Action
* @param null|string $path
*
* @return string|array|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
*
* @deprecated since 4.4.4, to be removed with version 4.5.0
*/
public function handleCreatePostAction(callable $callback, $path = null)
{
return $this->handlePostAction(function () use ($callback, $path) {
$result = $callback();
return $this->prepareRedirectMessageAfterPost($result, 'create', $path);
});
return $this->handleSaveAction($callback, $path);
}
/**
......@@ -188,28 +186,41 @@ class Action
* @param null|string $path
*
* @return string|array|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
*
* @deprecated since 4.4.4, to be removed with version 4.5.0
*/
public function handleEditPostAction(callable $callback, $path = null)
{
return $this->handleSaveAction($callback, $path);
}
/**
* @param callable $callback
* @param null|string $path
*
* @return array|string|JsonResponse|RedirectResponse
*/
public function handleSaveAction(callable $callback, $path = null)
{
return $this->handlePostAction(function () use ($callback, $path) {
$result = $callback();
return $this->prepareRedirectMessageAfterPost($result, 'edit', $path);
return $this->prepareRedirectMessageAfterPost($result, 'save', $path);
});
}
/**
* @param bool|int $result
* @param string $localization
* @param string $phrase
* @param null|string $path
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
*/
private function prepareRedirectMessageAfterPost($result, $localization, $path = null)
private function prepareRedirectMessageAfterPost($result, $phrase, $path = null)
{
return $this->redirectMessages->setMessage(
$result,
$this->translator->t('system', $localization . ($result !== false ? '_success' : '_error')),
$this->translator->t('system', $phrase . ($result !== false ? '_success' : '_error')),
$path
);
}
......
......@@ -80,7 +80,7 @@ class Create extends AbstractFormAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
$this->adminFormValidation->validate($formData);
$formData['user_id'] = $this->user->getUserId();
......
......@@ -85,7 +85,7 @@ class Edit extends AbstractFormAction
*/
protected function executePost(array $formData, $articleId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $articleId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $articleId) {
$this->adminFormValidation
->setUriAlias(sprintf(Articles\Helpers::URL_KEY_PATTERN, $articleId))
->validate($formData);
......
......@@ -77,7 +77,7 @@ class Create extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
$file = $this->request->getFiles()->get('picture');
$this->adminFormValidation
......
......@@ -82,7 +82,7 @@ class Edit extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData, array $category, $categoryId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $category, $categoryId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $category, $categoryId) {
$file = $this->request->getFiles()->get('picture');
$this->adminFormValidation
......
......@@ -100,7 +100,7 @@ class Edit extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData, array $comment, $commentId, $moduleId)
{
return $this->actionHelper->handleEditPostAction(
return $this->actionHelper->handleSaveAction(
function () use ($formData, $comment, $commentId) {
$this->adminFormValidation->validate($formData);
......
......@@ -71,7 +71,7 @@ class Create extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
$file = $this->request->getFiles()->get('picture');
$this->adminFormValidation
......
......@@ -82,7 +82,7 @@ class Edit extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData, array $emoticon, $emoticonId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $emoticon, $emoticonId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $emoticon, $emoticonId) {
$file = $this->request->getFiles()->get('picture');
$this->adminFormValidation
......
......@@ -106,7 +106,7 @@ class Create extends AbstractFormAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
if (isset($formData['external'])) {
$file = $formData['file_external'];
} else {
......
......@@ -120,7 +120,7 @@ class Edit extends AbstractFormAction
*/
protected function executePost(array $formData, array $dl, $fileId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $dl, $fileId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $dl, $fileId) {
$file = null;
if (isset($formData['external'])) {
$file = $formData['file_external'];
......
......@@ -79,7 +79,7 @@ class Create extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
$this->galleryFormValidation->validate($formData);
$formData['user_id'] = $this->user->getUserId();
......
......@@ -98,7 +98,7 @@ class Edit extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData, $galleryId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $galleryId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $galleryId) {
$this->galleryFormValidation
->setUriAlias(sprintf(Gallery\Helpers::URL_KEY_PATTERN_GALLERY, $galleryId))
->validate($formData);
......
......@@ -149,7 +149,7 @@ class Create extends AbstractFormAction
*/
protected function executePost(array $formData, array $settings, $galleryId)
{
return $this->actionHelper->handleCreatePostAction(
return $this->actionHelper->handleSaveAction(
function () use ($formData, $settings, $galleryId) {
/** @var UploadedFile $file */
$file = $this->request->getFiles()->get('file');
......
......@@ -111,7 +111,7 @@ class Edit extends AbstractFormAction
*/
protected function executePost(array $formData, array $settings, array $picture, $pictureId)
{
return $this->actionHelper->handleEditPostAction(
return $this->actionHelper->handleSaveAction(
function () use ($formData, $settings, $picture, $pictureId) {
/** @var UploadedFile $file */
$file = $this->request->getFiles()->get('file');
......
......@@ -96,7 +96,7 @@ class Edit extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData, array $settings, $guestbookId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $settings, $guestbookId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $settings, $guestbookId) {
$this->adminFormValidation
->setSettings($settings)
->validate($formData);
......
......@@ -71,7 +71,7 @@ class Create extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
$this->menuFormValidation->validate($formData);
return $this->menusModel->save($formData);
......
......@@ -83,7 +83,7 @@ class Edit extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData, $menuId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $menuId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $menuId) {
$this->menuFormValidation
->setMenuId($menuId)
->validate($formData);
......
......@@ -105,7 +105,7 @@ class Create extends AbstractFormAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(
return $this->actionHelper->handleSaveAction(
function () use ($formData) {
$this->menuItemFormValidation->validate($formData);
......
......@@ -117,7 +117,7 @@ class Edit extends AbstractFormAction
*/
protected function executePost(array $formData, array $menuItem, $menuItemId)
{
return $this->actionHelper->handleEditPostAction(
return $this->actionHelper->handleSaveAction(
function () use ($formData, $menuItem, $menuItemId) {
$this->menuItemFormValidation->validate($formData);
......
......@@ -95,7 +95,7 @@ class Create extends AbstractFormAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
$this->adminFormValidation->validate($formData);
$formData['cat'] = $this->fetchCategoryIdForSave($formData);
......
......@@ -98,7 +98,7 @@ class Edit extends AbstractFormAction
*/
protected function executePost(array $formData, $newsId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $newsId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $newsId) {
$this->adminFormValidation
->setUriAlias(sprintf(News\Helpers::URL_KEY_PATTERN, $newsId))
->validate($formData);
......
......@@ -86,7 +86,7 @@ class Create extends AbstractFormAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
$this->roleFormValidation->validate($formData);
$roleId = $this->roleModel->save($formData);
......
......@@ -100,7 +100,7 @@ class Edit extends AbstractFormAction
*/
protected function executePost(array $formData, $roleId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $roleId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $roleId) {
$this->roleFormValidation
->setRoleId($roleId)
->validate($formData);
......
......@@ -79,7 +79,7 @@ class Create extends AbstractFormAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
$this->resourceFormValidation->validate($formData);
$formData['module_id'] = $this->fetchModuleId($formData['modules']);
......
......@@ -92,7 +92,7 @@ class Edit extends AbstractFormAction
*/
protected function executePost(array $formData, $resourceId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $resourceId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $resourceId) {
$this->resourceFormValidation->validate($formData);
$formData['module_id'] = $this->fetchModuleId($formData['modules']);
......
......@@ -94,7 +94,7 @@ class Create extends AbstractFormAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
$this->pollsValidator->validate($formData);
$formData['user_id'] = $this->user->getUserId();
......
......@@ -94,7 +94,7 @@ class Edit extends AbstractFormAction
*/
protected function executePost(array $formData, $pollId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $pollId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $pollId) {
$this->pollsValidator->validate($formData);
$formData['user_id'] = $this->user->getUserId();
......
......@@ -86,7 +86,7 @@ class Create extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
$this->adminFormValidation->validate($formData);
return $this->seoModel->save($formData);
......
......@@ -92,7 +92,7 @@ class Edit extends Core\Controller\AbstractAdminAction
*/
protected function executePost(array $formData, $path, $seoId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $path, $seoId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $path, $seoId) {
$this->adminFormValidation
->setUriAlias($path)
->validate($formData);
......
......@@ -254,6 +254,8 @@
<item key="refresh">Aktualisieren</item>
<item key="reset">Zurücksetzen</item>
<item key="result">Ergebnis</item>
<item key="save_error">Beim Speichern des Eintrages ist ein Fehler aufgetreten.</item>
<item key="save_success">Der Eintrag wurde erfolgreich gespeichert.</item>
<item key="select_cache_images">Bitte wählen Sie aus, ob Bilder gecached werden sollen.</item>
<item key="select_date">Bitte vervollständigen Sie die Angaben zum Veröffentlichungsdatum bzw. dem Enddatum dieses Eintrages.</item>
<item key="select_date_format">Bitte wählen Sie aus, ob das lange oder das kurze Datumsformat verwendet werden soll.</item>
......
......@@ -254,6 +254,8 @@
<item key="refresh">Refresh</item>
<item key="reset">Reset</item>
<item key="result">Result</item>
<item key="save_error">While saving the entry an error has occurred.</item>
<item key="save_success">The entry has been successfully saved.</item>
<item key="select_cache_images">Please select whether you want to cache pictures.</item>
<item key="select_date">Please complete the details of the release date and end date.</item>
<item key="select_date_format">Please select whether the long or the short date format to be used.</item>
......
......@@ -115,7 +115,7 @@ class Create extends AbstractFormAction
*/
protected function executePost(array $formData)
{
return $this->actionHelper->handleCreatePostAction(function () use ($formData) {
return $this->actionHelper->handleSaveAction(function () use ($formData) {
$this->adminFormValidation->validate($formData);
$salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
......
......@@ -133,7 +133,7 @@ class Edit extends AbstractFormAction
*/
protected function executePost(array $formData, $userId)
{
return $this->actionHelper->handleEditPostAction(function () use ($formData, $userId) {
return $this->actionHelper->handleSaveAction(function () use ($formData, $userId) {
$this->adminFormValidation
->setUserId($userId)
->validate($formData);
......
......@@ -7,11 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] - 20016-xx-xx
### Changed
- Updated the CKEditor WYSIWYG-Editor to version 4.6
- Unified the `\ACP3\Core\Helper\Action::handleCreatePostAction()` and `\ACP3\Core\Helper\Action::handleEditPostAction()` methods into the new method `\ACP3\Core\Helper\Action::handleSaveAction()`
### Fixed
- Fixed the deleting of the category picture when deleting a category
- Fixed the deleting of the assigned menu item and SEO settings when deleting an article
### Deprecations
- Deprecated `\ACP3\Core\Helper\Action::handleCreatePostAction()`, use `\ACP3\Core\Helper\Action::handleSaveAction()` instead
- Deprecated `\ACP3\Core\Helper\Action::handleEditPostAction()`, use `\ACP3\Core\Helper\Action::handleSaveAction()` instead
## [4.4.3] - 20016-11-24
### Fixed
- Fixed the retrieval of the user context hash when the remember me cookie is set
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment