Skip to content

Commit

Permalink
Implemented copy locale feature in list and edit form
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Hopfner committed Feb 14, 2017
1 parent bec7610 commit 6f88c49
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 9 deletions.
14 changes: 14 additions & 0 deletions Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Sulu\Bundle\ArticleBundle\Document\Form\ArticleDocumentType;
use Sulu\Bundle\ArticleBundle\Metadata\ArticleViewDocumentIdTrait;
use Sulu\Component\Content\Form\Exception\InvalidFormException;
use Sulu\Component\Content\Mapper\ContentMapperInterface;
use Sulu\Component\DocumentManager\DocumentManagerInterface;
use Sulu\Component\Rest\Exception\MissingParameterException;
use Sulu\Component\Rest\Exception\RestException;
Expand Down Expand Up @@ -321,6 +322,7 @@ public function postTriggerAction($uuid, Request $request)
// prepare vars
$view = null;
$data = null;
$userId = $this->getUser()->getId();

try {
switch ($action) {
Expand All @@ -336,6 +338,10 @@ public function postTriggerAction($uuid, Request $request)
$this->getDocumentManager()->removeDraft($data, $locale);
$this->getDocumentManager()->flush();
break;
case 'copy-locale':
$destLocales = $this->getRequestParameter($request, 'dest', true);
$data = $this->getMapper()->copyLanguage($uuid, $userId, null, $locale, explode(',', $destLocales));
break;
default:
throw new RestException('Unrecognized action: ' . $action);
}
Expand Down Expand Up @@ -413,6 +419,14 @@ protected function getDocumentManager()
return $this->get('sulu_document_manager.document_manager');
}

/**
* @return ContentMapperInterface
*/
protected function getMapper()
{
return $this->get('sulu.content.mapper');
}

/**
* Delegates actions by given actionParameter, which can be retrieved from the request.
*
Expand Down
Loading

0 comments on commit 6f88c49

Please sign in to comment.