Skip to content

Commit

Permalink
Revert "EZP-27492 Content draft edit"
Browse files Browse the repository at this point in the history
This reverts commit dfee1a9.
  • Loading branch information
glye committed Aug 16, 2017
1 parent b411db7 commit e9b1081
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 318 deletions.
100 changes: 0 additions & 100 deletions bundle/Controller/ContentEditController.php
Expand Up @@ -12,13 +12,8 @@
use eZ\Publish\API\Repository\ContentService;
use eZ\Publish\API\Repository\ContentTypeService;
use eZ\Publish\API\Repository\LocationService;
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
use eZ\Publish\Core\Base\Exceptions\BadStateException;
use EzSystems\RepositoryForms\Data\Content\CreateContentDraftData;
use EzSystems\RepositoryForms\Data\Mapper\ContentCreateMapper;
use EzSystems\RepositoryForms\Data\Mapper\ContentUpdateMapper;
use EzSystems\RepositoryForms\Form\ActionDispatcher\ActionDispatcherInterface;
use EzSystems\RepositoryForms\Form\Type\Content\ContentDraftCreateType;
use EzSystems\RepositoryForms\Form\Type\Content\ContentEditType;
use Symfony\Component\HttpFoundation\Request;

Expand Down Expand Up @@ -95,101 +90,6 @@ public function createWithoutDraftAction($contentTypeIdentifier, $language, $par
]);
}

/**
* Displays a draft creation form that creates a content draft from an existing content.
*
* @param mixed $contentId
* @param int $fromVersionNo
* @param string $fromLanguage
* @param string $toLanguage
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function createContentDraftAction($contentId, $fromVersionNo = null, $fromLanguage = null, $toLanguage = null, Request $request)
{
$createContentDraft = new CreateContentDraftData();

if ($contentId !== null) {
$createContentDraft->contentId = $contentId;

$contentInfo = $this->contentService->loadContentInfo($contentId);
$createContentDraft->fromVersionNo = $fromVersionNo ?: $contentInfo->currentVersionNo;
$createContentDraft->fromLanguage = $fromLanguage ?: $contentInfo->mainLanguageCode;
}

$form = $this->createForm(
ContentDraftCreateType::class,
$createContentDraft,
[
'action' => $this->generateUrl('ez_content_draft_create'),
]
);

$form->handleRequest($request);

if ($form->isValid()) {
$this->contentActionDispatcher->dispatchFormAction($form, $createContentDraft, $form->getClickedButton()->getName());
if ($response = $this->contentActionDispatcher->getResponse()) {
return $response;
}
}

return $this->render('@EzSystemsRepositoryForms/Content/content_create_draft.html.twig', [
'form' => $form->createView(),
'pagelayout' => $this->pagelayout,
]);
}

/**
* Shows a content draft editing form.
*
* @param int $contentId ContentType id to create
* @param int $versionNo Version number the version should be created from. Defaults to the currently published one.
* @param \Symfony\Component\HttpFoundation\Request $request
* @param string $language Language code to create the version in (eng-GB, ger-DE, ...))
*
* @return \Symfony\Component\HttpFoundation\Response
* @throws \eZ\Publish\Core\Base\Exceptions\BadStateException If the version isn't editable, or if there is no editable version.
*/
public function editContentDraftAction($contentId, $versionNo = null, Request $request, $language = null)
{
$draft = $this->contentService->loadContent($contentId, [$language], $versionNo);
if ($draft->getVersionInfo()->status !== VersionInfo::STATUS_DRAFT) {
throw new BadStateException('Version status', 'status is not draft');
}

$contentUpdate = (new ContentUpdateMapper())->mapToFormData(
$draft,
[
'languageCode' => $language,
'contentType' => $this->contentTypeService->loadContentType($draft->contentInfo->contentTypeId),
]
);
$form = $this->createForm(
ContentEditType::class,
$contentUpdate,
[
'languageCode' => $language,
'drafts_enabled' => true,
]
);
$form->handleRequest($request);

if ($form->isValid()) {
$this->contentActionDispatcher->dispatchFormAction($form, $contentUpdate, $form->getClickedButton()->getName());
if ($response = $this->contentActionDispatcher->getResponse()) {
return $response;
}
}

return $this->render('EzSystemsRepositoryFormsBundle:Content:content_edit.html.twig', [
'form' => $form->createView(),
'languageCode' => $language,
'pagelayout' => $this->pagelayout,
]);
}

/**
* @param string $pagelayout
* @return ContentEditController
Expand Down
15 changes: 0 additions & 15 deletions bundle/Resources/config/routing.yml
Expand Up @@ -3,21 +3,6 @@ ez_content_create_no_draft:
defaults:
_controller: ez_content_edit:createWithoutDraftAction

ez_content_edit:
path: /content/edit/{contentId}/{versionNo}/{language}
defaults:
_controller: ez_content_edit:editContentDraftAction
language: null

ez_content_draft_create:
path: /content/create/draft/{contentId}/{fromVersionNo}/{fromLanguage}/{toLanguage}
defaults:
_controller: ez_content_edit:createContentDraftAction
contentId: null
fromVersionNo: null
fromLanguage: null
toLanguage: null

ez_user_register:
path: /register
defaults:
Expand Down
7 changes: 0 additions & 7 deletions bundle/Resources/views/Content/content_create_draft.html.twig

This file was deleted.

58 changes: 0 additions & 58 deletions doc/specifications/content_edit.md

This file was deleted.

28 changes: 0 additions & 28 deletions lib/Data/Content/ContentUpdateData.php

This file was deleted.

19 changes: 0 additions & 19 deletions lib/Data/Content/CreateContentDraftData.php

This file was deleted.

2 changes: 1 addition & 1 deletion lib/Data/Mapper/ContentUpdateMapper.php
Expand Up @@ -29,7 +29,7 @@ public function mapToFormData(ValueObject $contentDraft, array $params = [])
$this->configureOptions($optionsResolver);
$params = $optionsResolver->resolve($params);

$data = new ContentUpdateData(['contentDraft' => $contentDraft]);
$data = new ContentUpdateData(['contentDraft' => $contentDraft, 'contentType' => $params['contentType']]);
$fields = $contentDraft->getFieldsByLanguage($params['languageCode']);
foreach ($params['contentType']->fieldDefinitions as $fieldDef) {
$field = $fields[$fieldDef->identifier];
Expand Down
5 changes: 0 additions & 5 deletions lib/Event/RepositoryFormEvents.php
Expand Up @@ -52,11 +52,6 @@ final class RepositoryFormEvents
*/
const CONTENT_SAVE_DRAFT = 'content.edit.saveDraft';

/**
* Triggered when creating a content draft.
*/
const CONTENT_CREATE_DRAFT = 'content.edit.createDraft';

/**
* Triggered when publishing a content.
*/
Expand Down
20 changes: 1 addition & 19 deletions lib/Form/Processor/ContentFormProcessor.php
Expand Up @@ -45,7 +45,6 @@ public static function getSubscribedEvents()
RepositoryFormEvents::CONTENT_PUBLISH => ['processPublish', 10],
RepositoryFormEvents::CONTENT_CANCEL => ['processRemoveDraft', 10],
RepositoryFormEvents::CONTENT_SAVE_DRAFT => ['processSaveDraft', 10],
RepositoryFormEvents::CONTENT_CREATE_DRAFT => ['processCreateDraft', 10],
];
}

Expand All @@ -61,7 +60,7 @@ public function processSaveDraft(FormActionEvent $event)

$defaultUrl = $this->router->generate('ez_content_edit', [
'contentId' => $draft->id,
'versionNo' => $draft->getVersionInfo()->versionNo,
'version' => $draft->getVersionInfo()->versionNo,
'language' => $languageCode,
]);
$event->setResponse(new RedirectResponse($formConfig->getAction() ?: $defaultUrl));
Expand Down Expand Up @@ -104,23 +103,6 @@ public function processRemoveDraft(FormActionEvent $event)
$event->setResponse(new RedirectResponse($url));
}

public function processCreateDraft(FormActionEvent $event)
{
/** @var $createContentDraft \EzSystems\RepositoryForms\Data\Content\CreateContentDraftData */
$createContentDraft = $event->getData();

$contentInfo = $this->contentService->loadContentInfo($createContentDraft->contentId);
$versionInfo = $this->contentService->loadVersionInfo($contentInfo, $createContentDraft->fromVersionNo);
$contentDraft = $this->contentService->createContentDraft($contentInfo, $versionInfo);

$contentEditUrl = $this->router->generate('ez_content_edit', [
'contentId' => $contentDraft->id,
'versionNo' => $contentDraft->getVersionInfo()->versionNo,
'language' => $contentDraft->contentInfo->mainLanguageCode,
]);
$event->setResponse(new RedirectResponse($contentEditUrl));
}

/**
* Saves content draft corresponding to $data.
* Depending on the nature of $data (create or update data), the draft will either be created or simply updated.
Expand Down
66 changes: 0 additions & 66 deletions lib/Form/Type/Content/ContentDraftCreateType.php

This file was deleted.

0 comments on commit e9b1081

Please sign in to comment.