1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Task runner, code generator and build tool for easier continuos integration |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/hiqdev/hidev |
7
|
|
|
* @package hidev |
8
|
|
|
* @license BSD-3-Clause |
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace hidev\controllers; |
13
|
|
|
|
14
|
|
|
use hidev\helpers\Helper; |
15
|
|
|
use yii\base\InvalidParamException; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Init controller. |
19
|
|
|
* Builds .hidev/config.yml by template and params. |
20
|
|
|
*/ |
21
|
|
|
class InitController extends TemplateController |
22
|
|
|
{ |
23
|
|
|
protected $_file = '.hidev/config.yml'; |
24
|
|
|
|
25
|
|
|
public $vendor; |
26
|
|
|
public $package; |
27
|
|
|
|
28
|
|
|
public function prepareData($name) |
29
|
|
|
{ |
30
|
|
|
list($vendor, $package) = explode('/', $name, 2); |
31
|
|
|
if ($vendor) { |
32
|
|
|
$this->vendor = $vendor; |
33
|
|
|
$vendorPlugin = "$vendor/hidev-vendor"; |
34
|
|
|
try { |
35
|
|
|
$exists = @file_get_contents("https://packagist.org/packages/$vendorPlugin.json"); |
36
|
|
|
} catch (Exception $e) { |
|
|
|
|
37
|
|
|
$exists = false; |
38
|
|
|
} |
39
|
|
|
if ($exists) { |
40
|
|
|
$this->setItem('vendorRequire', str_pad($vendorPlugin . ':', 23) . ' "*"'); |
|
|
|
|
41
|
|
|
$this->setItem('novendor', true); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
if ($package) { |
45
|
|
|
$this->package = $package; |
46
|
|
|
} |
47
|
|
|
if (!$this->package || !$this->vendor) { |
48
|
|
|
throw new InvalidParamException('Wrong vendor/package given: ' . $name); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function actionPerform($name = null, $template = '.hidev/config') |
53
|
|
|
{ |
54
|
|
|
$this->_template = $template; |
55
|
|
|
$this->prepareData($name); |
56
|
|
|
if (!file_exists($this->dirname)) { |
|
|
|
|
57
|
|
|
mkdir($this->dirname); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return parent::actionPerform(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function options($actionId) |
64
|
|
|
{ |
65
|
|
|
return array_merge(parent::options($actionId), explode(',', 'namespace,headline,title,type,license,keywords,description,year,nick,author,email,novendor,norequire')); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getType() |
69
|
|
|
{ |
70
|
|
|
return $this->getItem('type') ?: 'project'; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getTitle() |
74
|
|
|
{ |
75
|
|
|
return $this->getItem('title') ?: Helper::titleize($this->package); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getKeywords() |
79
|
|
|
{ |
80
|
|
|
return $this->getItem('keywords') ?: implode(', ', explode('-', $this->package)); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/// TODO think of better getting nick |
84
|
|
|
public function getNick() |
85
|
|
|
{ |
86
|
|
|
return $this->getItem('nick') ?: preg_replace('/[^a-zA-Z_0-9]+/', '', `id -un`); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function getAuthor() |
90
|
|
|
{ |
91
|
|
|
return $this->getItem('author') ?: $this->takeVcs()->getUserName(); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getEmail() |
95
|
|
|
{ |
96
|
|
|
return $this->getItem('email') ?: $this->takeVcs()->getUserEmail(); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.