Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
4c09aef2
Commit
4c09aef2
authored
Apr 25, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created Appcontroller to make it easiert to debug
controller links application vendor to yiidev repo
parent
1ce52a53
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
0 deletions
+106
-0
AppController.php
build/controllers/AppController.php
+106
-0
No files found.
build/controllers/AppController.php
0 → 100644
View file @
4c09aef2
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\build\controllers
;
use
Yii
;
use
yii\base\InvalidParamException
;
use
yii\console\Controller
;
use
yii\helpers\Console
;
use
yii\helpers\FileHelper
;
/**
* AppController will link the yii2 dev installation to the containted applications vendor dirs
* to help working on yii using the application to test it.
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class
AppController
extends
Controller
{
public
$defaultAction
=
'link'
;
/**
* This command runs the following shell commands in the dev repo root:
*
* - Run `composer update`
* - `rm -rf apps/basic/vendor/yiisoft/yii2`
* - `rm -rf apps/basic/vendor/yiisoft/yii2-*`
*
* And replaces them with symbolic links to the extensions and framework path in the dev repo.
* @param string $app the application name `basic` or `advanced`.
*/
public
function
actionLink
(
$app
)
{
// root of the dev repo
$base
=
dirname
(
dirname
(
__DIR__
));
$appDir
=
"
$base
/apps/
$app
"
;
// cleanup
if
(
is_link
(
$link
=
"
$appDir
/vendor/yiisoft/yii2"
))
{
$this
->
stdout
(
"Removing symlink
$link
.
\n
"
);
unlink
(
$link
);
}
$extensions
=
$this
->
findDirs
(
"
$appDir
/vendor/yiisoft"
);
foreach
(
$extensions
as
$ext
)
{
if
(
is_link
(
$link
=
"
$appDir
/vendor/yiisoft/yii2-
$ext
"
))
{
$this
->
stdout
(
"Removing symlink
$link
.
\n
"
);
unlink
(
$link
);
}
}
// composer update
chdir
(
$appDir
);
passthru
(
'composer update --prefer-dist'
);
// link directories
if
(
is_dir
(
$link
=
"
$appDir
/vendor/yiisoft/yii2"
))
{
$this
->
stdout
(
"Removing dir
$link
.
\n
"
);
FileHelper
::
removeDirectory
(
$link
);
$this
->
stdout
(
"Creating symlink for
$link
.
\n
"
);
symlink
(
"
$base
/framework"
,
$link
);
}
$extensions
=
$this
->
findDirs
(
"
$appDir
/vendor/yiisoft"
);
foreach
(
$extensions
as
$ext
)
{
if
(
is_dir
(
$link
=
"
$appDir
/vendor/yiisoft/yii2-
$ext
"
))
{
$this
->
stdout
(
"Removing dir
$link
.
\n
"
);
FileHelper
::
removeDirectory
(
$link
);
$this
->
stdout
(
"Creating symlink for
$link
.
\n
"
);
symlink
(
"
$base
/extensions/
$ext
"
,
$link
);
}
}
$this
->
stdout
(
"done.
\n
"
);
}
protected
function
findDirs
(
$dir
)
{
$list
=
[];
$handle
=
@
opendir
(
$dir
);
if
(
$handle
===
false
)
{
return
[];
}
while
((
$file
=
readdir
(
$handle
))
!==
false
)
{
if
(
$file
===
'.'
||
$file
===
'..'
)
{
continue
;
}
$path
=
$dir
.
DIRECTORY_SEPARATOR
.
$file
;
if
(
is_dir
(
$path
)
&&
preg_match
(
'/^yii2-(.*)$/'
,
$file
,
$matches
))
{
$list
[]
=
$matches
[
1
];
}
}
closedir
(
$handle
);
foreach
(
$list
as
$i
=>
$e
)
{
if
(
$e
==
'composer'
)
{
// skip composer to not break composer update
unset
(
$list
[
$i
]);
}
}
return
$list
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment