1
|
|
|
<?php namespace Anomaly\DashboardModule\Seeder; |
2
|
|
|
|
3
|
|
|
use Anomaly\ConfigurationModule\Configuration\Contract\ConfigurationRepositoryInterface; |
4
|
|
|
use Anomaly\DashboardModule\Dashboard\Contract\DashboardRepositoryInterface; |
5
|
|
|
use Anomaly\DashboardModule\Widget\Contract\WidgetRepositoryInterface; |
6
|
|
|
use Anomaly\Streams\Platform\Database\Seeder\Seeder; |
7
|
|
|
use Anomaly\XmlFeedWidgetExtension\XmlFeedWidgetExtension; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class WidgetSeeder |
11
|
|
|
* |
12
|
|
|
* @link http://pyrocms.com/ |
13
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
14
|
|
|
* @author Ryan Thompson <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class WidgetSeeder extends Seeder |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* The widget repository. |
21
|
|
|
* |
22
|
|
|
* @var WidgetRepositoryInterface |
23
|
|
|
*/ |
24
|
|
|
protected $widgets; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* The dashboard repository. |
28
|
|
|
* |
29
|
|
|
* @var DashboardRepositoryInterface |
30
|
|
|
*/ |
31
|
|
|
protected $dashboards; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The configuration repository. |
35
|
|
|
* |
36
|
|
|
* @var ConfigurationRepositoryInterface |
37
|
|
|
*/ |
38
|
|
|
protected $configuration; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Create a new WidgetSeeder instance. |
42
|
|
|
* |
43
|
|
|
* @param WidgetRepositoryInterface $widgets |
44
|
|
|
* @param DashboardRepositoryInterface $dashboards |
45
|
|
|
* @param ConfigurationRepositoryInterface $configuration |
46
|
|
|
*/ |
47
|
|
|
public function __construct( |
48
|
|
|
WidgetRepositoryInterface $widgets, |
49
|
|
|
DashboardRepositoryInterface $dashboards, |
50
|
|
|
ConfigurationRepositoryInterface $configuration |
51
|
|
|
) { |
52
|
|
|
$this->widgets = $widgets; |
53
|
|
|
$this->dashboards = $dashboards; |
54
|
|
|
$this->configuration = $configuration; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Run the seeder. |
59
|
|
|
*/ |
60
|
|
|
public function run() |
61
|
|
|
{ |
62
|
|
|
$this->widgets->truncate(); |
63
|
|
|
|
64
|
|
|
$dashboard = $this->dashboards->findBySlug('welcome'); |
65
|
|
|
|
66
|
|
|
$widget = $this->widgets |
67
|
|
|
->create( |
68
|
|
|
[ |
69
|
|
|
'en' => [ |
70
|
|
|
'title' => 'Recent News', |
71
|
|
|
'description' => 'Recent news from http://pyrocms.com/', |
72
|
|
|
], |
73
|
|
|
'extension' => 'anomaly.extension.xml_feed_widget', |
74
|
|
|
'dashboard' => $dashboard, |
75
|
|
|
] |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
$this->configuration->purge('anomaly.extension.xml_feed_widget'); |
79
|
|
|
|
80
|
|
|
$this->configuration->create( |
81
|
|
|
[ |
82
|
|
|
'scope' => $widget->getId(), |
83
|
|
|
'key' => 'anomaly.extension.xml_feed_widget::url', |
84
|
|
|
'value' => 'http://www.pyrocms.com/posts/rss.xml', |
85
|
|
|
] |
86
|
|
|
); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|