|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: egorov |
|
5
|
|
|
* Date: 12.02.2015 |
|
6
|
|
|
* Time: 11:33 |
|
7
|
|
|
*/ |
|
8
|
|
|
namespace samsonphp\compressor; |
|
9
|
|
|
|
|
10
|
|
|
use samson\core\Service; |
|
11
|
|
|
use samsonphp\event\Event; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* UI module controller |
|
15
|
|
|
* @package samsonphp\compressor |
|
16
|
|
|
* @author Vitaly Iegorov <[email protected]> |
|
17
|
|
|
*/ |
|
18
|
|
|
class Controller extends Service |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
/** Module identifier */ |
|
21
|
|
|
protected $id = 'compressor'; |
|
22
|
|
|
|
|
23
|
|
|
/** Output path for compressed web application */ |
|
24
|
|
|
public $output = 'out/'; |
|
25
|
|
|
|
|
26
|
|
|
/** @var array Configuration parameters key => value collection */ |
|
27
|
|
|
public $configuration = array(); |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param mixed $entityConfiguration current instance for configuration |
|
31
|
|
|
* @return boolean False if something went wrong otherwise true |
|
32
|
|
|
*/ |
|
33
|
|
|
public function configure($entityConfiguration) |
|
34
|
|
|
{ |
|
35
|
|
|
// Convert object to array |
|
36
|
|
|
$this->configuration = (array)$entityConfiguration; |
|
37
|
|
|
// Set fileServiceClassName parameter from config |
|
38
|
|
|
if (!empty($this->configuration['output']{0})) { |
|
39
|
|
|
$this->output = $this->configuration['output']; |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Panel render handler |
|
47
|
|
|
* @param string $output HTML output |
|
48
|
|
|
* @param array $data View variables collection |
|
49
|
|
|
* @param \samson\core\Module $module Active module pointer |
|
50
|
|
|
*/ |
|
51
|
|
|
public function panelRenderer(&$output, $data, $module) |
|
|
|
|
|
|
52
|
|
|
{ |
|
53
|
|
|
//$output .= $this->view('panel/index')->output(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Compress web-application |
|
58
|
|
|
* @param boolean $debug Disable errors output |
|
59
|
|
|
* @param string $environment Configuration environment |
|
60
|
|
|
* @param string $phpVersion PHP version to support |
|
61
|
|
|
*/ |
|
62
|
|
|
public function __handler($debug = false, $environment = 'prod', $phpVersion = PHP_VERSION) |
|
63
|
|
|
{ |
|
64
|
|
|
$compressor = new Compressor($this->output, $debug, $environment, $phpVersion, $this->configuration); |
|
65
|
|
|
$compressor->compress($debug, $environment, $phpVersion); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** Controller action for compressing debug version of web-application */ |
|
69
|
|
|
public function __debug($environment = '') |
|
70
|
|
|
{ |
|
71
|
|
|
$this->__HANDLER(true, $environment); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
This class, trait or interface has been deprecated.