1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Superdesk Web Publisher Content Bundle. |
5
|
|
|
* |
6
|
|
|
* Copyright 2016 Sourcefabric z.ú. and contributors. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please see the |
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @copyright 2016 Sourcefabric z.ú |
12
|
|
|
* @license http://www.superdesk.org/license |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace SWP\Bundle\ContentBundle\Factory\PHPCR; |
16
|
|
|
|
17
|
|
|
use SWP\Bundle\ContentBundle\Doctrine\ODM\PHPCR\ArticleInterface; |
18
|
|
|
use SWP\Bundle\ContentBundle\Factory\AbstractArticleFactory; |
19
|
|
|
use SWP\Bundle\ContentBundle\Provider\ArticleProviderInterface; |
20
|
|
|
use SWP\Bundle\ContentBundle\Provider\RouteProviderInterface; |
21
|
|
|
use SWP\Component\Bridge\Model\PackageInterface; |
22
|
|
|
use SWP\Component\Storage\Factory\FactoryInterface; |
23
|
|
|
|
24
|
|
|
class ArticleFactory extends AbstractArticleFactory |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var FactoryInterface |
28
|
|
|
*/ |
29
|
|
|
private $baseFactory; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var ArticleProviderInterface |
33
|
|
|
*/ |
34
|
|
|
private $articleProvider; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
private $contentRelativePath; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* ArticleFactory constructor. |
43
|
|
|
* |
44
|
|
|
* @param FactoryInterface $baseFactory |
45
|
|
|
* @param RouteProviderInterface $routeProvider |
46
|
|
|
* @param ArticleProviderInterface $articleProvider |
47
|
|
|
* @param string $contentRelativePath |
48
|
|
|
*/ |
49
|
|
|
public function __construct( |
50
|
|
|
FactoryInterface $baseFactory, |
51
|
|
|
RouteProviderInterface $routeProvider, |
52
|
|
|
ArticleProviderInterface $articleProvider, |
53
|
|
|
string $contentRelativePath |
54
|
|
|
) { |
55
|
|
|
$this->baseFactory = $baseFactory; |
56
|
|
|
$this->articleProvider = $articleProvider; |
57
|
|
|
$this->contentRelativePath = $contentRelativePath; |
58
|
|
|
|
59
|
|
|
parent::__construct($routeProvider); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* {@inheritdoc} |
64
|
|
|
*/ |
65
|
|
|
public function create() |
66
|
|
|
{ |
67
|
|
|
return $this->baseFactory->create(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
|
|
public function createFromPackage(PackageInterface $package) |
74
|
|
|
{ |
75
|
|
|
/** @var ArticleInterface $article */ |
76
|
|
|
$article = $this->hydrateArticle($package); |
77
|
|
|
|
78
|
|
|
$article->setParentDocument($this->articleProvider->getParent($this->contentRelativePath)); |
79
|
|
|
|
80
|
|
|
return $article; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|