1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Maps\Elements; |
4
|
|
|
|
5
|
|
|
use Maps\Element; |
6
|
|
|
use Maps\ElementOptions; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Base class for objects implementing the @see Element interface. |
10
|
|
|
* |
11
|
|
|
* @since 3.0 |
12
|
|
|
* |
13
|
|
|
* @licence GNU GPL v2+ |
14
|
|
|
* @author Kim Eik < [email protected] > |
15
|
|
|
* @author Jeroen De Dauw < [email protected] > |
16
|
|
|
*/ |
17
|
|
|
abstract class BaseElement implements Element { |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var ElementOptions |
21
|
|
|
*/ |
22
|
|
|
protected $options; |
23
|
|
|
|
24
|
|
|
public function __construct() { |
25
|
|
|
$this->options = new ElementOptions(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function setTitle( string $title ) { |
29
|
|
|
$this->options->setOption( 'title', $title ); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function setText( string $text ) { |
33
|
|
|
$this->options->setOption( 'text', $text ); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function setLink( string $link ) { |
37
|
|
|
$this->options->setOption( 'link', $link ); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function getArrayValue() { |
41
|
|
|
return $this->getJSONObject(); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @deprecated |
46
|
|
|
* |
47
|
|
|
* @param string $defText |
48
|
|
|
* @param string $defTitle |
49
|
|
|
* |
50
|
|
|
* @return array |
51
|
|
|
*/ |
52
|
|
|
public function getJSONObject( string $defText = '', string $defTitle = '' ): array { |
53
|
|
|
$array = []; |
54
|
|
|
|
55
|
|
|
$array['text'] = $this->options->hasOption( 'text' ) ? $this->getText() : $defText; |
56
|
|
|
$array['title'] = $this->options->hasOption( 'title' ) ? $this->getTitle() : $defTitle; |
57
|
|
|
$array['link'] = $this->options->hasOption( 'link' ) ? $this->getLink() : ''; |
58
|
|
|
|
59
|
|
|
return $array; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getText(): string { |
63
|
|
|
return $this->options->getOption( 'text' ); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getTitle(): string { |
67
|
|
|
return $this->options->getOption( 'title' ); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getLink(): string { |
71
|
|
|
return $this->options->getOption( 'link' ); |
72
|
|
|
} |
73
|
|
|
|
74
|
8 |
|
public function getOptions(): ElementOptions { |
75
|
8 |
|
return $this->options; |
76
|
|
|
} |
77
|
|
|
|
78
|
4 |
|
public function setOptions( ElementOptions $options ) { |
79
|
4 |
|
$this->options = $options; |
80
|
4 |
|
} |
81
|
|
|
|
82
|
|
|
} |
83
|
|
|
|
This method has been deprecated.