1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace eNTiDi\FeedReader; |
4
|
|
|
|
5
|
|
|
use Page; |
|
|
|
|
6
|
|
|
use SilverStripe\Core\Injector\Injector; |
7
|
|
|
use SilverStripe\Forms\NumericField; |
8
|
|
|
use SilverStripe\Forms\TextField; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Defines the FeedReaderPage page type. |
12
|
|
|
*/ |
13
|
|
|
class FeedReaderPage extends Page |
14
|
|
|
{ |
15
|
|
|
private static $table_name = 'FeedReaderPage'; |
|
|
|
|
16
|
|
|
|
17
|
|
|
private static $db = [ |
|
|
|
|
18
|
|
|
'FeedUrl' => 'Varchar(254)', |
19
|
|
|
'SummaryLen' => 'Int', |
20
|
|
|
'Expiration' => 'Int' |
21
|
|
|
]; |
22
|
|
|
|
23
|
|
|
private static $defaults = [ |
|
|
|
|
24
|
|
|
'SummaryLen' => 255, |
25
|
|
|
'Expiration' => 3600, |
26
|
|
|
]; |
27
|
|
|
|
28
|
|
|
private $service; |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
public function getCMSFields() |
32
|
|
|
{ |
33
|
|
|
$t_FeedUrl = _t(__CLASS__.'.FEED_URL', 'Feed URL'); |
34
|
|
|
$t_SummaryLen = _t(__CLASS__.'.SUMMARY_LEN', 'Summary length'); |
35
|
|
|
$d_SummaryLen = _t(__CLASS__.'.SUMMARY_LEN_COMMENT', 'Maximum length of the summary field (in bytes) when it is generated programmatically'); |
36
|
|
|
$t_Expiration = _t(__CLASS__.'.EXPIRATION', 'Cache timeout'); |
37
|
|
|
$d_Expiration = _t(__CLASS__.'.EXPIRATION_COMMENT', 'How many seconds a cached copy must be accessed instead of downloading the real feed'); |
38
|
|
|
|
39
|
|
|
$fields = parent::getCMSFields(); |
40
|
|
|
$fields->addFieldsToTab('Root.Feed', [ |
41
|
|
|
TextField::create('FeedUrl', $t_FeedUrl), |
|
|
|
|
42
|
|
|
NumericField::create('SummaryLen', $t_SummaryLen) |
43
|
|
|
->setDescription($d_SummaryLen), |
44
|
|
|
NumericField::create('Expiration', $t_Expiration) |
45
|
|
|
->setDescription($d_Expiration), |
46
|
|
|
]); |
47
|
|
|
return $fields; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getService() |
51
|
|
|
{ |
52
|
|
|
if (! $this->service) { |
53
|
|
|
$this->service = Injector::inst()->create( |
54
|
|
|
'eNTiDi\FeedReader\FeedReaderService', |
55
|
|
|
$this->FeedUrl, |
56
|
|
|
(int) $this->Expiration |
57
|
|
|
); |
58
|
|
|
$this->service->setSummaryLen($this->SummaryLen); |
59
|
|
|
} |
60
|
|
|
return $this->service; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function Items($count = null) |
64
|
|
|
{ |
65
|
|
|
$items = $this->getService()->getItems(); |
66
|
|
|
|
67
|
|
|
// When $count is null, limit() will use array_slice(..., 0, null) |
68
|
|
|
// internally, meaning a clone of $items will be returned |
69
|
|
|
return $items->limit($count); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths