|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Yosymfony\Spress\Core\DataSource\Item; |
|
4
|
|
|
use Yosymfony\Spress\Core\DataSource\Memory\MemoryDataSource; |
|
5
|
|
|
use Yosymfony\Spress\Core\Plugin\PluginInterface; |
|
6
|
|
|
use Yosymfony\Spress\Core\Plugin\EventSubscriber; |
|
7
|
|
|
use Yosymfony\Spress\Core\Plugin\Event\EnvironmentEvent; |
|
8
|
|
|
use Yosymfony\Spress\Core\Plugin\Event\ContentEvent; |
|
9
|
|
|
use Yosymfony\Spress\Core\Plugin\Event\FinishEvent; |
|
10
|
|
|
use Yosymfony\Spress\Core\Plugin\Event\RenderEvent; |
|
11
|
|
|
|
|
12
|
|
|
class TestPlugin implements PluginInterface |
|
13
|
|
|
{ |
|
14
|
|
|
public function getMetas() |
|
15
|
|
|
{ |
|
16
|
|
|
return [ |
|
17
|
|
|
'name' => 'Test plugin', |
|
18
|
|
|
]; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function initialize(EventSubscriber $subscriber) |
|
22
|
|
|
{ |
|
23
|
|
|
$subscriber->addEventListener('spress.start', 'onStart'); |
|
|
|
|
|
|
24
|
|
|
$subscriber->addEventListener('spress.before_convert', 'onBeforeConvert'); |
|
|
|
|
|
|
25
|
|
|
$subscriber->addEventListener('spress.after_convert', 'onAfterConvert'); |
|
|
|
|
|
|
26
|
|
|
$subscriber->addEventListener('spress.before_render_blocks', 'onBeforeRenderBlocks'); |
|
|
|
|
|
|
27
|
|
|
$subscriber->addEventListener('spress.after_render_blocks', 'onAfterRenderBlocks'); |
|
|
|
|
|
|
28
|
|
|
$subscriber->addEventListener('spress.before_render_page', 'onBeforeRenderPage'); |
|
|
|
|
|
|
29
|
|
|
$subscriber->addEventListener('spress.after_render_page', 'onAfterRenderPage'); |
|
|
|
|
|
|
30
|
|
|
$subscriber->addEventListener('spress.finish', 'onFinish'); |
|
|
|
|
|
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function onStart(EnvironmentEvent $event) |
|
34
|
|
|
{ |
|
35
|
|
|
$dsm = $event->getDataSourceManager(); |
|
36
|
|
|
|
|
37
|
|
|
$item = new Item('Content from item in memory data source', 'memory-datasource.txt'); |
|
38
|
|
|
$item->setPath('memory-datasource.txt', Item::SNAPSHOT_PATH_RELATIVE); |
|
39
|
|
|
|
|
40
|
|
|
$memoryDataSource = new MemoryDataSource(); |
|
41
|
|
|
$memoryDataSource->addItem($item); |
|
42
|
|
|
|
|
43
|
|
|
$dsm->setDataSource('memory-plugin', $memoryDataSource); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function onBeforeConvert(ContentEvent $event) |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function onAfterConvert(ContentEvent $event) |
|
|
|
|
|
|
51
|
|
|
{ |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function onBeforeRenderBlocks(RenderEvent $event) |
|
|
|
|
|
|
55
|
|
|
{ |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function onAfterRenderBlocks(RenderEvent $event) |
|
|
|
|
|
|
59
|
|
|
{ |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function onBeforeRenderPage(RenderEvent $event) |
|
|
|
|
|
|
63
|
|
|
{ |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function onAfterRenderPage(RenderEvent $event) |
|
|
|
|
|
|
67
|
|
|
{ |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function onFinish(FinishEvent $event) |
|
|
|
|
|
|
71
|
|
|
{ |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: