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