Test Failed
Push — master ( 794710...4acb1e )
by Georgi
03:38
created

LaunchPad::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Epesi\Core\Layout\View;
4
5
use Illuminate\Support\Facades\URL;
6
use atk4\ui\jsExpression;
7
use atk4\ui\VirtualPage;
8
use Closure;
9
use Epesi\Core\System\View\LaunchButton;
10
11
class LaunchPad extends jsExpression
12
{
13
	protected $parent;
14
	
15
	public function __construct($parent)
16
	{
17
    	$this->parent = $parent;
18
    	
19
		parent::__construct('$(this).atkCreateModal([arg])', [
20
				'arg' => [
21
						'uri' => $this->getURL(),
22
						'title' => __('Launchpad'),
23
						'mode' => 'json'
24
				]
25
		]);
26
	}
27
    
28
	protected function getURL()
29
    {
30
    	return $this->parent->add('VirtualPage')->set(Closure::fromCallable([$this, 'getContents']))->getJSURL('cut');
31
    }
32
    
33
    protected function getContents(VirtualPage $vp)
34
    {
35
    	$vp->add([
36
    			new LaunchButton([
37
    					'label' => 'Test Button 1',
38
    					'icon' => 'user'
39
    			])
40
    	])->link(URL::to('/'));
41
    	$vp->add([
42
    			new LaunchButton([
43
    					'label' => 'Test Button 2',
44
    					'icon' => 'car'
45
    			])
46
    	]);
47
    	$vp->add([
48
    			new LaunchButton([
49
    					'label' => 'Test Button 3',
50
    					'icon' => 'bus'
51
    			])
52
    	]);
53
    }
54
}
55