-
Notifications
You must be signed in to change notification settings - Fork 0
/
PackagesController.php
78 lines (64 loc) · 1.67 KB
/
PackagesController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace mito\assets;
use Yii;
use yii\console\Controller;
use yii\helpers\Json;
use yii\di\Instance;
/**
* This command returns information about asset bundles for gulp/grunt.
*/
class PackagesController extends Controller
{
/**
* @var path to main config file
*/
public $configPath;
/**
* @var string|array|\mito\assets\BundleManager bundle manger component
*/
public $bundleManager = 'bundleManager';
/**
* @inheritdoc
*/
public function options($actionID)
{
return array_merge(
parent::options($actionID),
['configPath'] // global for all actions
);
}
public function init()
{
parent::init();
$this->bundleManager = Instance::ensure($this->bundleManager, BundleManager::className());
}
public function beforeAction($action)
{
if (!parent::beforeAction($action)) {
return false;
}
if (isset($this->configPath)) {
$this->bundleManager->configPath = $this->configPath;
}
return true;
}
/**
* This command checks if any of the package files are newer than their directory,
* and touches the directory to force Yii to publish it again.
*/
public function actionDeploy()
{
$directories = $this->bundleManager->deploy();
foreach ($directories as $directory) {
echo "Touched $directory\n";
}
}
/**
* This command returns information about asset bundles for gulp/grunt.
*/
public function actionIndex()
{
$ret = $this->bundleManager->getBundleInfo();
echo Json::encode($ret);
}
}