Passed
Push — develop ( b3eda6...9f2d35 )
by Daniel
03:59 queued 40s
created

multi_select   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 43
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A prep_field() 0 5 1
A build_multi_select() 0 6 1
A get_name() 0 3 1
A get_template() 0 3 1
1
<?php
2
3
/**
4
 *
5
 * @package sitemaker
6
 * @copyright (c) 2019 Daniel A. (blitze)
7
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
8
 *
9
 */
10
11
namespace blitze\sitemaker\services\blocks\config\fields;
12
13
use blitze\sitemaker\services\blocks\config\cfg_utils;
14
15
/**
16
 * @package sitemaker
17
 */
18
class multi_select extends cfg_field_base
19
{
20
	/**
21
	 * @inheritdoc
22
	 */
23
	public function get_name()
24
	{
25
		return 'multi_select';
26
	}
27
28
	/**
29
	 * {@inheritdoc}
30
	 */
31
	public function prep_field(array &$vars, array &$type, $field, array $db_settings)
32
	{
33
		$vars['method'] = 'build_multi_select';
34
		$vars['params'][] = $field;
35
		$type[0] = 'custom';
36
	}
37
38
	/**
39
	 * Used to add multi-select drop down in blocks config
40
	 *
41
	 * @param array $option_ary
42
	 * @param mixed $selected_items
43
	 * @param string $field
44
	 * @return array
45
	 */
46
	public function build_multi_select(array $option_ary, $selected_items, $field)
47
	{
48
		return array(
49
			'field'		=> $field,
50
			'options'	=> $option_ary,
51
			'selected'	=> cfg_utils::ensure_array($selected_items),
52
		);
53
	}
54
55
	/**
56
	 * {@inheritdoc}
57
	 */
58
	public function get_template()
59
	{
60
		return '@blitze_sitemaker/cfg_fields/multi_select.html';
61
	}
62
}
63