Completed
Push — master ( d19955...af891e )
by Sam
22s
created

PopoverField   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 58
rs 10
wmc 5
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPopoverTitle() 0 4 1
A setPopoverTitle() 0 5 1
A getSchemaDataDefaults() 0 15 3
1
<?php
2
3
/**
4
 * Popup form action menu for "more options"
5
 *
6
 * Only works with react forms at the moment
7
 */
8
class PopoverField extends FieldGroup
9
{
10
	private static $cast = [
11
		'PopoverTitle' => 'HTMLText'
12
	];
13
14
	/**
15
	 * Use custom react component
16
	 *
17
	 * @var string
18
	 */
19
	protected $schemaComponent = 'PopoverField';
20
21
	/**
22
	 * Optional title on popup box
23
	 *
24
	 * @var string
25
	 */
26
	protected $popoverTitle = null;
27
28
	/**
29
	 * Get popup title
30
	 *
31
	 * @return string
32
	 */
33
	public function getPopoverTitle()
34
	{
35
		return $this->popoverTitle;
36
	}
37
38
	/**
39
	 * Set popup title
40
	 *
41
	 * @param string $popoverTitle
42
	 * @return $this
43
	 */
44
	public function setPopoverTitle($popoverTitle)
45
	{
46
		$this->popoverTitle = $popoverTitle;
47
		return $this;
48
	}
49
50
	public function getSchemaDataDefaults()
51
	{
52
		$schema = parent::getSchemaDataDefaults();
53
		if($this->getPopoverTitle()) {
54
			$data = [
55
				'popoverTitle' => $this->getPopoverTitle()
56
			];
57
			if(isset($schema['data'])) {
58
				$schema['data'] = array_merge($schema['data'], $data);
59
			} else {
60
				$schema['data'] = $data;
61
			}
62
		}
63
		return $schema;
64
	}
65
}
66