-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
125 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
/* | ||
* HiDev - integrate your development | ||
* | ||
* @link https://hidev.me/ | ||
* @package hidev | ||
* @license BSD-3-Clause | ||
* @copyright Copyright (c) 2014-2015, HiQDev (https://hiqdev.com/) | ||
*/ | ||
|
||
namespace hidev\goals; | ||
|
||
use hidev\helpers\Helper; | ||
use yii\base\InvalidParamException; | ||
|
||
/** | ||
* Init goal to build files by template and params. | ||
*/ | ||
class InitGoal extends TemplateGoal | ||
{ | ||
protected $_file = '.hidev/config.yml'; | ||
|
||
protected $_fileType = 'template'; | ||
|
||
public function actionPerform($name, $template = '.hidev/config') | ||
{ | ||
list($vendor, $package) = explode('/', $name, 2); | ||
if (!$package || !$vendor) { | ||
throw new InvalidParamException('No vendor/package given'); | ||
} | ||
$this->vendor = $vendor; | ||
$this->package = $package; | ||
$this->template = $template; | ||
|
||
if (!file_exists($this->dirname)) { | ||
mkdir($this->dirname); | ||
} | ||
|
||
return parent::actionPerform(); | ||
} | ||
|
||
public function options($actionId) | ||
{ | ||
return array_merge(parent::options($actionId), explode(',', 'label,title,type,keywords,year')); | ||
} | ||
|
||
public function getPackage() | ||
{ | ||
return $this->getItem('package'); | ||
} | ||
|
||
public function getTitle() | ||
{ | ||
return $this->getItem('title') ?: Helper::titleize($this->package); | ||
} | ||
|
||
public function getLabel() | ||
{ | ||
return $this->getItem('label') ?: Helper::id2camel($this->package); | ||
} | ||
|
||
public function getType() | ||
{ | ||
return $this->getItem('type') ?: 'package'; | ||
} | ||
|
||
public function getKeywords() | ||
{ | ||
return $this->getItem('keywords') ?: implode(', ', explode('-', $this->package)); | ||
} | ||
|
||
public function getYear() | ||
{ | ||
return $this->getItem('year') ?: date('Y'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package: | ||
name: {{ config.init.package }} | ||
label: {{ config.init.label }} | ||
title: {{ config.init.title }} | ||
type: {{ config.init.type }} | ||
keywords: {{ config.init.keywords }} | ||
year: {{ config.init.year }} | ||
|
||
require: | ||
{{ config.init.vendor }}/hidev-config: "*" | ||
hiqdev/hidev-config-php: "*" |