Passed
Push — 2.1.0 ( ...c750ab )
by steve
15:24
created

ImageMultiple   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 16
dl 0
loc 40
ccs 0
cts 25
cp 0
rs 10
c 1
b 0
f 1
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getValueDisplay() 0 15 4
A getFilterField() 0 3 1
A getComponentDetails() 0 4 1
1
<?php
2
3
4
namespace neon\core\form\fields;
5
6
7
use neon\core\helpers\Html;
8
9
class ImageMultiple extends Field
10
{
11
	/**
12
	 * @inheritdoc
13
	 */
14
	public $ddsDataType = 'json';
15
16
	/**
17
	 * @inheritdoc
18
	 */
19
	public function getFilterField()
20
	{
21
		return ['class' => 'neon\\core\\form\\fields\\Text'];
22
	}
23
24
	/**
25
	 * @inheritdoc
26
	 */
27
	public function getComponentDetails()
28
	{
29
		return [
30
			'icon' => 'fa fa-image', 'group' => 'Media', 'order' => 80
31
		];
32
	}
33
34
	public function getValueDisplay($context='')
35
	{
36
		$json = $this->getValue();
37
		if (empty($json))
38
			return neon()->formatter->asJson($this->getValue());
39
		if ($context==='grid') {
40
			$out = '';
41
			$images = json_decode($json);
42
			foreach($images as $image) {
43
				$url = neon()->firefly->getImage($image);
44
				$out .= "<img src='$url' />";
45
			}
46
			return $out;
47
		}
48
		return neon()->formatter->asJson($this->getValue());
49
	}
50
}
51