|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of Sulu. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) MASSIVE ART WebServices GmbH |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sulu\Bundle\ArticleBundle\Command; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Move articles from given parent-page to another. |
|
21
|
|
|
*/ |
|
22
|
|
|
class MovePageTreeCommand extends ContainerAwareCommand |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* {@inheritdoc} |
|
26
|
|
|
*/ |
|
27
|
|
|
public function configure() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->setName('sulu:article:page-tree:move') |
|
30
|
|
|
->addArgument('source-segment', InputArgument::REQUIRED) |
|
31
|
|
|
->addArgument('destination-segment', InputArgument::REQUIRED) |
|
32
|
|
|
->addArgument('webspace-key', InputArgument::REQUIRED) |
|
33
|
|
|
->addArgument('locale', InputArgument::REQUIRED); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* {@inheritdoc} |
|
38
|
|
|
*/ |
|
39
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
40
|
|
|
{ |
|
41
|
|
|
$source = $input->getArgument('source-segment'); |
|
42
|
|
|
$destination = $input->getArgument('destination-segment'); |
|
43
|
|
|
$webspaceKey = $input->getArgument('webspace-key'); |
|
44
|
|
|
$locale = $input->getArgument('locale'); |
|
45
|
|
|
|
|
46
|
|
|
$mover = $this->getContainer()->get('sulu_article.page_tree_route.mover'); |
|
47
|
|
|
$strategyPool = $this->getContainer()->get('sulu.content.resource_locator.strategy_pool'); |
|
48
|
|
|
$documentManager = $this->getContainer()->get('sulu_document_manager.document_manager'); |
|
49
|
|
|
$strategy = $strategyPool->getStrategyByWebspaceKey($webspaceKey); |
|
50
|
|
|
|
|
51
|
|
|
$destinationUuid = $strategy->loadByResourceLocator($destination, $webspaceKey, $locale); |
|
52
|
|
|
$document = $documentManager->find($destinationUuid, $locale); |
|
53
|
|
|
|
|
54
|
|
|
$mover->move($source, $document); |
|
55
|
|
|
|
|
56
|
|
|
$documentManager->flush(); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|