1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Superdesk Web Publisher Core Bundle. |
7
|
|
|
* |
8
|
|
|
* Copyright 2017 Sourcefabric z.ú. and contributors. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please see the |
11
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
12
|
|
|
* |
13
|
|
|
* @copyright 2017 Sourcefabric z.ú |
14
|
|
|
* @license http://www.superdesk.org/license |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace SWP\Bundle\CoreBundle\Model; |
18
|
|
|
|
19
|
|
|
use SWP\Bundle\AnalyticsBundle\Model\ArticleEventsTrait; |
20
|
|
|
use SWP\Bundle\AnalyticsBundle\Model\ContentListsAwareTrait; |
21
|
|
|
use SWP\Bundle\ContentBundle\Model\Article as BaseArticle; |
22
|
|
|
use SWP\Component\MultiTenancy\Model\OrganizationAwareTrait; |
23
|
|
|
use SWP\Component\MultiTenancy\Model\TenantAwareTrait; |
24
|
|
|
use SWP\Component\Paywall\Model\PaywallSecuredTrait; |
25
|
|
|
|
26
|
|
|
class Article extends BaseArticle implements ArticleInterface |
27
|
|
|
{ |
28
|
|
|
use TenantAwareTrait, OrganizationAwareTrait, PaywallSecuredTrait, ArticleEventsTrait, ContentListsAwareTrait; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var PackageInterface |
32
|
|
|
*/ |
33
|
|
|
protected $package; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var bool |
37
|
|
|
*/ |
38
|
|
|
protected $isPublishedFBIA = false; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var ArticleStatisticsInterface |
42
|
|
|
*/ |
43
|
|
|
protected $articleStatistics; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var ExternalArticleInterface |
47
|
|
|
*/ |
48
|
|
|
protected $externalArticle; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var int |
52
|
|
|
*/ |
53
|
|
|
protected $commentsCount; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
public function setId($id) |
59
|
|
|
{ |
60
|
|
|
$this->id = $id; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
*/ |
66
|
|
|
public function getPackage(): ?PackageInterface |
67
|
|
|
{ |
68
|
|
|
return $this->package; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* {@inheritdoc} |
73
|
|
|
*/ |
74
|
|
|
public function setPackage(PackageInterface $package) |
75
|
|
|
{ |
76
|
|
|
$this->package = $package; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* {@inheritdoc} |
81
|
|
|
*/ |
82
|
|
|
public function isPublishedFBIA(): bool |
83
|
|
|
{ |
84
|
|
|
return $this->isPublishedFBIA; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* {@inheritdoc} |
89
|
|
|
*/ |
90
|
|
|
public function setPublishedFBIA(bool $isPublished) |
91
|
|
|
{ |
92
|
|
|
$this->isPublishedFBIA = $isPublished; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* {@inheritdoc} |
97
|
|
|
*/ |
98
|
|
|
public function getArticleStatistics(): ?ArticleStatisticsInterface |
99
|
|
|
{ |
100
|
|
|
return $this->articleStatistics; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* {@inheritdoc} |
105
|
|
|
*/ |
106
|
|
|
public function setArticleStatistics(ArticleStatisticsInterface $articleStatistics): void |
107
|
|
|
{ |
108
|
|
|
$articleStatistics->setArticle($this); |
109
|
|
|
$this->articleStatistics = $articleStatistics; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* {@inheritdoc} |
114
|
|
|
*/ |
115
|
|
|
public function getExternalArticle(): ?ExternalArticleInterface |
116
|
|
|
{ |
117
|
|
|
return $this->externalArticle; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* {@inheritdoc} |
122
|
|
|
*/ |
123
|
|
|
public function setExternalArticle(ExternalArticleInterface $externalArticle): void |
124
|
|
|
{ |
125
|
|
|
$this->externalArticle = $externalArticle; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function getPackageExternalData() |
129
|
|
|
{ |
130
|
|
|
if (null === $this->getPackage()->getExternalData()) { |
131
|
|
|
return []; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
$data = []; |
135
|
|
|
foreach ($this->getPackage()->getExternalData() as $singleData) { |
136
|
|
|
$data[$singleData->getKey()] = $singleData->getValue(); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
return $data; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function getCommentsCount(): int |
143
|
|
|
{ |
144
|
|
|
if (null === $this->commentsCount) { |
145
|
|
|
return 0; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
return $this->commentsCount; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function setCommentsCount(int $commentsCount): void |
152
|
|
|
{ |
153
|
|
|
$this->commentsCount = $commentsCount; |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|