|
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\Document\Initializer; |
|
13
|
|
|
|
|
14
|
|
|
use Sulu\Bundle\DocumentManagerBundle\Initializer\InitializerInterface; |
|
15
|
|
|
use Sulu\Component\DocumentManager\NodeManager; |
|
16
|
|
|
use Sulu\Component\DocumentManager\PathBuilder; |
|
17
|
|
|
use Sulu\Component\PHPCR\SessionManager\SessionManagerInterface; |
|
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Initializes custom-url nodes. |
|
22
|
|
|
*/ |
|
23
|
|
|
class ArticleInitializer implements InitializerInterface |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var NodeManager |
|
27
|
|
|
*/ |
|
28
|
|
|
private $nodeManager; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var PathBuilder |
|
32
|
|
|
*/ |
|
33
|
|
|
private $pathBuilder; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var SessionManagerInterface |
|
37
|
|
|
*/ |
|
38
|
|
|
private $sessionManager; |
|
39
|
|
|
|
|
40
|
1 |
|
public function __construct( |
|
41
|
|
|
NodeManager $nodeManager, |
|
42
|
|
|
PathBuilder $pathBuilder, |
|
43
|
|
|
SessionManagerInterface $sessionManager |
|
44
|
|
|
) { |
|
45
|
1 |
|
$this->nodeManager = $nodeManager; |
|
46
|
1 |
|
$this->pathBuilder = $pathBuilder; |
|
47
|
1 |
|
$this->sessionManager = $sessionManager; |
|
48
|
1 |
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* {@inheritdoc} |
|
52
|
|
|
*/ |
|
53
|
1 |
|
public function initialize(OutputInterface $output, $purge = false) |
|
54
|
|
|
{ |
|
55
|
1 |
|
$nodeTypeManager = $this->sessionManager->getSession()->getWorkspace()->getNodeTypeManager(); |
|
|
|
|
|
|
56
|
1 |
|
$nodeTypeManager->registerNodeType(new ArticleNodeType(), true); |
|
57
|
1 |
|
$nodeTypeManager->registerNodeType(new ArticlePageNodeType(), true); |
|
58
|
|
|
|
|
59
|
1 |
|
$articlesPath = $this->pathBuilder->build(['%base%', '%articles%']); |
|
60
|
1 |
|
if (true === $this->nodeManager->has($articlesPath)) { |
|
61
|
|
|
$output->writeln(sprintf(' [ ] <info>Articles path:</info>: %s ', $articlesPath)); |
|
62
|
|
|
} else { |
|
63
|
1 |
|
$output->writeln(sprintf(' [+] <info>Articles path:</info>: %s ', $articlesPath)); |
|
64
|
1 |
|
$this->nodeManager->createPath($articlesPath); |
|
65
|
1 |
|
$this->nodeManager->save(); |
|
66
|
|
|
} |
|
67
|
1 |
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.