Skip to content

Commit

Permalink
fixed cding to prjdir
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Apr 13, 2016
1 parent 60927c7 commit d10132e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/controllers/StartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class StartController extends CommonController
*/
public function actionMake()
{
$this->getPrjDir();
$this->takeConfig()->includeConfig(static::MAIN_CONFIG);
$this->addAliases();
$this->addAutoloader();
Expand Down Expand Up @@ -73,10 +74,10 @@ public function actionUpdate()
*/
public function addAliases()
{
Yii::setAlias('@prjdir', $this->findPrjDir());
Yii::setAlias('@prjdir', $this->getPrjDir());
$config = $this->takeConfig()->rawItem('package');
$alias = '@' . strtr($config['namespace'], '\\', '/');
if ($alias && !Yii::getAlias($alias, false)) {
$alias = strtr($config['namespace'], '\\', '/');
if ($alias && !Yii::getAlias('@' . $alias, false)) {
$srcdir = Yii::getAlias('@prjdir/' . ($config['src'] ?: 'src'));
Yii::setAlias($alias, $srcdir);
}
Expand Down Expand Up @@ -130,6 +131,16 @@ public function loadConfig()
}
}


public function getPrjDir()
{
if ($this->prjdir === null) {
$this->prjdir = $this->findPrjDir();
}

return $this->prjdir;
}

/**
* Chdirs to project's root by looking for config file in the current directory and up.
* @throws InvalidParamException when failed to find
Expand Down

0 comments on commit d10132e

Please sign in to comment.