1 | <?php |
||
19 | class TimelineBuilder implements TimelineBuilderInterface |
||
20 | { |
||
21 | protected $options; |
||
22 | protected $addJs; |
||
23 | protected $filteredAttr; |
||
24 | |||
25 | /** |
||
26 | * @param WidgetOptionsInterface $options |
||
27 | */ |
||
28 | 4 | public function __construct(WidgetOptionsInterface $options) |
|
32 | |||
33 | /** |
||
34 | * @return string |
||
35 | */ |
||
36 | 3 | protected function buildWidget() |
|
37 | { |
||
38 | 3 | $attributesList = $this->filteredAttr; |
|
39 | 3 | $widget = '<a'; |
|
40 | |||
41 | 3 | foreach ($attributesList as $attrKey => $attrValue) { |
|
42 | 1 | $widget .= ' ' . $attrKey . '="' . $attrValue . '"'; |
|
43 | } |
||
44 | 3 | $widget .= '>'; |
|
45 | 3 | $widget .= $this->options['href_text']; |
|
46 | 3 | $widget .= '</a>'; |
|
47 | |||
48 | 3 | if ($this->addJs) { |
|
49 | 1 | return $widget . "\n<script>" . $this->getSingleWidgetJs() . "</script>"; |
|
50 | } |
||
51 | |||
52 | 2 | return $widget; |
|
53 | } |
||
54 | |||
55 | /** |
||
56 | * @param bool $addJs |
||
57 | * @return string |
||
58 | * @throws InvalidArgumentException |
||
59 | */ |
||
60 | 4 | public function renderWidget($addJs = true) |
|
70 | |||
71 | /** |
||
72 | * @return string |
||
73 | * |
||
74 | * Add the necessary code for a single widget |
||
75 | */ |
||
76 | 1 | protected function getSingleWidgetJs() |
|
88 | |||
89 | /** |
||
90 | * @return array |
||
91 | */ |
||
92 | 1 | protected function filterAttr() |
|
114 | } |
||
115 |