2008-05-30 11:40:08 +00:00
< ? php
/**
* The Project Task handles creating the base application
*
*
2010-10-03 16:38:58 +00:00
* PHP 5
2008-05-30 11:40:08 +00:00
*
2009-11-06 06:46:59 +00:00
* CakePHP ( tm ) : Rapid Development Framework ( http :// cakephp . org )
2013-02-08 11:59:49 +00:00
* Copyright ( c ) Cake Software Foundation , Inc . ( http :// cakefoundation . org )
2008-05-30 11:40:08 +00:00
*
* Licensed under The MIT License
2013-02-08 12:22:51 +00:00
* For full copyright and license information , please see the LICENSE . txt
2008-05-30 11:40:08 +00:00
* Redistributions of files must retain the above copyright notice .
*
2013-02-08 11:59:49 +00:00
* @ copyright Copyright ( c ) Cake Software Foundation , Inc . ( http :// cakefoundation . org )
2009-11-06 06:00:11 +00:00
* @ link http :// cakephp . org CakePHP ( tm ) Project
2008-10-30 17:30:26 +00:00
* @ since CakePHP ( tm ) v 1.2
2013-05-30 22:11:14 +00:00
* @ license http :// www . opensource . org / licenses / mit - license . php MIT License
2008-05-30 11:40:08 +00:00
*/
2010-12-08 00:20:56 +00:00
2011-11-25 21:05:00 +00:00
App :: uses ( 'AppShell' , 'Console/Command' );
2010-12-08 00:20:56 +00:00
App :: uses ( 'File' , 'Utility' );
2011-04-17 16:03:43 +00:00
App :: uses ( 'Folder' , 'Utility' );
2011-03-07 05:55:05 +00:00
App :: uses ( 'String' , 'Utility' );
App :: uses ( 'Security' , 'Utility' );
2010-10-30 03:26:18 +00:00
2008-05-30 11:40:08 +00:00
/**
* Task class for creating new project apps and plugins
*
2011-07-26 06:16:14 +00:00
* @ package Cake . Console . Command . Task
2008-05-30 11:40:08 +00:00
*/
2011-11-25 21:05:00 +00:00
class ProjectTask extends AppShell {
2009-07-24 19:18:37 +00:00
2009-07-01 00:44:09 +00:00
/**
* configs path ( used in testing ) .
*
* @ var string
2009-11-14 12:19:25 +00:00
*/
2010-04-04 07:14:00 +00:00
public $configPath = null ;
2009-07-24 19:18:37 +00:00
2008-05-30 11:40:08 +00:00
/**
* Checks that given project path does not already exist , and
* finds the app directory in it . Then it calls bake () with that information .
*
2011-07-29 02:03:44 +00:00
* @ return mixed
2008-05-30 11:40:08 +00:00
*/
2010-10-16 05:02:15 +00:00
public function execute () {
$project = null ;
if ( isset ( $this -> args [ 0 ])) {
$project = $this -> args [ 0 ];
2012-06-02 19:10:23 +00:00
} else {
$appContents = array_diff ( scandir ( APP ), array ( '.' , '..' ));
if ( empty ( $appContents )) {
$suggestedPath = rtrim ( APP , DS );
} else {
$suggestedPath = APP . 'myapp' ;
}
2008-05-30 11:40:08 +00:00
}
while ( ! $project ) {
2011-04-17 16:12:25 +00:00
$prompt = __d ( 'cake_console' , " What is the path to the project you want to bake? " );
2012-06-02 19:10:23 +00:00
$project = $this -> in ( $prompt , null , $suggestedPath );
2008-05-30 11:40:08 +00:00
}
2011-08-16 03:55:08 +00:00
2011-05-22 12:49:51 +00:00
if ( $project && ! Folder :: isAbsolute ( $project ) && isset ( $_SERVER [ 'PWD' ])) {
$project = $_SERVER [ 'PWD' ] . DS . $project ;
}
$response = false ;
2012-09-14 17:26:30 +00:00
while ( ! $response && is_dir ( $project ) === true && file_exists ( $project . 'Config' . 'core.php' )) {
2011-05-22 12:49:51 +00:00
$prompt = __d ( 'cake_console' , '<warning>A project already exists in this location:</warning> %s Overwrite?' , $project );
2011-12-01 07:21:31 +00:00
$response = $this -> in ( $prompt , array ( 'y' , 'n' ), 'n' );
2011-05-22 12:49:51 +00:00
if ( strtolower ( $response ) === 'n' ) {
$response = $project = false ;
2008-05-30 11:40:08 +00:00
}
}
2010-10-18 02:38:32 +00:00
$success = true ;
2008-10-23 00:10:44 +00:00
if ( $this -> bake ( $project )) {
2008-05-30 11:40:08 +00:00
$path = Folder :: slashTerm ( $project );
2010-10-18 02:38:32 +00:00
if ( $this -> securitySalt ( $path ) === true ) {
2011-03-19 17:32:35 +00:00
$this -> out ( __d ( 'cake_console' , ' * Random hash key created for \'Security.salt\'' ));
2008-05-30 11:40:08 +00:00
} else {
2011-04-17 11:13:02 +00:00
$this -> err ( __d ( 'cake_console' , 'Unable to generate random hash for \'Security.salt\', you should change it in %s' , APP . 'Config' . DS . 'core.php' ));
2010-10-18 02:38:32 +00:00
$success = false ;
2008-05-30 11:40:08 +00:00
}
2010-10-18 02:38:32 +00:00
if ( $this -> securityCipherSeed ( $path ) === true ) {
2011-03-19 17:32:35 +00:00
$this -> out ( __d ( 'cake_console' , ' * Random seed created for \'Security.cipherSeed\'' ));
2010-01-25 16:14:18 +00:00
} else {
2011-04-17 11:13:02 +00:00
$this -> err ( __d ( 'cake_console' , 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s' , APP . 'Config' . DS . 'core.php' ));
2010-10-18 02:38:32 +00:00
$success = false ;
2010-01-25 16:14:18 +00:00
}
2012-01-23 00:54:34 +00:00
if ( $this -> cachePrefix ( $path )) {
$this -> out ( __d ( 'cake_console' , ' * Cache prefix set' ));
} else {
$this -> err ( __d ( 'cake_console' , 'The cache prefix was <error>NOT</error> set' ));
$success = false ;
}
2010-10-18 02:38:32 +00:00
if ( $this -> consolePath ( $path ) === true ) {
2011-04-12 02:13:40 +00:00
$this -> out ( __d ( 'cake_console' , ' * app/Console/cake.php path set.' ));
2010-10-18 02:38:32 +00:00
} else {
2011-04-12 02:13:40 +00:00
$this -> err ( __d ( 'cake_console' , 'Unable to set console path for app/Console.' ));
2010-10-18 02:38:32 +00:00
$success = false ;
}
2011-07-30 17:41:43 +00:00
$hardCode = false ;
2011-08-04 01:56:24 +00:00
if ( $this -> cakeOnIncludePath ()) {
$this -> out ( __d ( 'cake_console' , '<info>CakePHP is on your `include_path`. CAKE_CORE_INCLUDE_PATH will be set, but commented out.</info>' ));
2011-07-13 21:54:24 +00:00
} else {
2011-07-30 17:41:43 +00:00
$this -> out ( __d ( 'cake_console' , '<warning>CakePHP is not on your `include_path`, CAKE_CORE_INCLUDE_PATH will be hard coded.</warning>' ));
$this -> out ( __d ( 'cake_console' , 'You can fix this by adding CakePHP to your `include_path`.' ));
$hardCode = true ;
}
2011-08-04 01:56:24 +00:00
$success = $this -> corePath ( $path , $hardCode ) === true ;
if ( $success ) {
2013-08-20 22:05:53 +00:00
$this -> out ( __d ( 'cake_console' , ' * CAKE_CORE_INCLUDE_PATH set to %s in %s' , CAKE_CORE_INCLUDE_PATH , 'webroot/index.php' ));
$this -> out ( __d ( 'cake_console' , ' * CAKE_CORE_INCLUDE_PATH set to %s in %s' , CAKE_CORE_INCLUDE_PATH , 'webroot/test.php' ));
2011-07-13 21:54:24 +00:00
} else {
2012-03-05 03:49:38 +00:00
$this -> err ( __d ( 'cake_console' , 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s' , $path . 'webroot' . DS . 'index.php' ));
2011-07-30 17:41:43 +00:00
$success = false ;
2011-07-13 21:54:24 +00:00
}
2011-08-04 01:56:24 +00:00
if ( $success && $hardCode ) {
$this -> out ( __d ( 'cake_console' , ' * <warning>Remember to check these values after moving to production server</warning>' ));
2011-07-13 21:54:24 +00:00
}
2008-05-30 11:40:08 +00:00
$Folder = new Folder ( $path );
if ( ! $Folder -> chmod ( $path . 'tmp' , 0777 )) {
2012-03-05 03:49:38 +00:00
$this -> err ( __d ( 'cake_console' , 'Could not set permissions on %s' , $path . DS . 'tmp' ));
2013-05-22 09:15:01 +00:00
$this -> out ( 'chmod -R 0777 ' . $path . DS . 'tmp' );
2010-10-18 02:38:32 +00:00
$success = false ;
2008-05-30 11:40:08 +00:00
}
2010-10-18 02:38:32 +00:00
if ( $success ) {
2011-03-19 17:32:35 +00:00
$this -> out ( __d ( 'cake_console' , '<success>Project baked successfully!</success>' ));
2010-10-18 02:38:32 +00:00
} else {
2011-03-19 17:32:35 +00:00
$this -> out ( __d ( 'cake_console' , 'Project baked but with <warning>some issues.</warning>.' ));
2008-05-30 11:40:08 +00:00
}
2010-10-23 04:35:53 +00:00
return $path ;
2008-05-30 11:40:08 +00:00
}
}
2009-07-24 19:18:37 +00:00
2011-07-30 17:41:43 +00:00
/**
* Checks PHP ' s include_path for CakePHP .
*
2011-08-19 02:31:00 +00:00
* @ return boolean Indicates whether or not CakePHP exists on include_path
2011-07-30 17:41:43 +00:00
*/
public function cakeOnIncludePath () {
$paths = explode ( PATH_SEPARATOR , ini_get ( 'include_path' ));
foreach ( $paths as $path ) {
if ( file_exists ( $path . DS . 'Cake' . DS . 'bootstrap.php' )) {
return true ;
}
}
return false ;
}
2008-05-30 11:40:08 +00:00
/**
* Looks for a skeleton template of a Cake application ,
* and if not found asks the user for a path . When there is a path
* this method will make a deep copy of the skeleton to the project directory .
*
* @ param string $path Project path
* @ param string $skel Path to copy from
* @ param string $skip array of directories to skip when copying
2011-07-29 02:03:44 +00:00
* @ return mixed
2008-05-30 11:40:08 +00:00
*/
2011-05-30 20:02:32 +00:00
public function bake ( $path , $skel = null , $skip = array ( 'empty' )) {
2011-04-16 17:22:53 +00:00
if ( ! $skel && ! empty ( $this -> params [ 'skel' ])) {
2008-05-30 11:40:08 +00:00
$skel = $this -> params [ 'skel' ];
}
while ( ! $skel ) {
2011-04-16 18:15:15 +00:00
$skel = $this -> in (
__d ( 'cake_console' , " What is the path to the directory layout you wish to copy? " ),
null ,
2011-05-31 03:02:39 +00:00
CAKE . 'Console' . DS . 'Templates' . DS . 'skel'
2011-04-16 18:15:15 +00:00
);
if ( ! $skel ) {
2011-03-19 17:32:35 +00:00
$this -> err ( __d ( 'cake_console' , 'The directory path you supplied was empty. Please try again.' ));
2008-05-30 11:40:08 +00:00
} else {
while ( is_dir ( $skel ) === false ) {
2011-04-16 18:15:15 +00:00
$skel = $this -> in (
__d ( 'cake_console' , 'Directory path does not exist please choose another:' ),
null ,
2011-05-31 03:02:39 +00:00
CAKE . 'Console' . DS . 'Templates' . DS . 'skel'
2011-04-16 18:15:15 +00:00
);
2008-05-30 11:40:08 +00:00
}
}
}
$app = basename ( $path );
2011-03-19 17:32:35 +00:00
$this -> out ( __d ( 'cake_console' , '<info>Skel Directory</info>: ' ) . $skel );
$this -> out ( __d ( 'cake_console' , '<info>Will be copied to</info>: ' ) . $path );
2008-05-30 11:40:08 +00:00
$this -> hr ();
2011-03-19 17:32:35 +00:00
$looksGood = $this -> in ( __d ( 'cake_console' , 'Look okay?' ), array ( 'y' , 'n' , 'q' ), 'y' );
2008-05-30 11:40:08 +00:00
2011-05-22 12:56:19 +00:00
switch ( strtolower ( $looksGood )) {
case 'y' :
$Folder = new Folder ( $skel );
if ( ! empty ( $this -> params [ 'empty' ])) {
$skip = array ();
}
2010-10-17 23:01:44 +00:00
2011-05-22 12:56:19 +00:00
if ( $Folder -> copy ( array ( 'to' => $path , 'skip' => $skip ))) {
$this -> hr ();
$this -> out ( __d ( 'cake_console' , '<success>Created:</success> %s in %s' , $app , $path ));
$this -> hr ();
} else {
$this -> err ( __d ( 'cake_console' , " <error>Could not create</error> '%s' properly. " , $app ));
return false ;
}
2008-05-30 11:40:08 +00:00
2011-05-22 12:56:19 +00:00
foreach ( $Folder -> messages () as $message ) {
$this -> out ( String :: wrap ( ' * ' . $message ), 1 , Shell :: VERBOSE );
}
2008-05-30 11:40:08 +00:00
2011-05-22 12:56:19 +00:00
return true ;
case 'n' :
unset ( $this -> args [ 0 ]);
$this -> execute ();
return false ;
case 'q' :
$this -> out ( __d ( 'cake_console' , '<error>Bake Aborted.</error>' ));
return false ;
2008-05-30 11:40:08 +00:00
}
}
2009-07-24 19:18:37 +00:00
2010-10-18 02:38:32 +00:00
/**
* Generates the correct path to the CakePHP libs that are generating the project
* and points app / console / cake . php to the right place
*
* @ param string $path Project path .
* @ return boolean success
*/
public function consolePath ( $path ) {
2011-04-12 02:13:40 +00:00
$File = new File ( $path . 'Console' . DS . 'cake.php' );
2010-10-18 02:38:32 +00:00
$contents = $File -> read ();
if ( preg_match ( '/(__CAKE_PATH__)/' , $contents , $match )) {
2011-07-30 17:41:43 +00:00
$root = strpos ( CAKE_CORE_INCLUDE_PATH , '/' ) === 0 ? " \$ ds . ' " : " ' " ;
$replacement = $root . str_replace ( DS , " ' . \$ ds . ' " , trim ( CAKE_CORE_INCLUDE_PATH , DS )) . " ' " ;
2010-10-18 02:38:32 +00:00
$result = str_replace ( $match [ 0 ], $replacement , $contents );
if ( $File -> write ( $result )) {
return true ;
}
return false ;
}
return false ;
}
2008-05-30 11:40:08 +00:00
/**
* Generates and writes 'Security.salt'
*
* @ param string $path Project path
* @ return boolean Success
*/
2010-04-05 03:19:38 +00:00
public function securitySalt ( $path ) {
2011-05-13 08:06:45 +00:00
$File = new File ( $path . 'Config' . DS . 'core.php' );
2008-05-30 11:40:08 +00:00
$contents = $File -> read ();
2010-10-17 23:07:57 +00:00
if ( preg_match ( '/([\s]*Configure::write\(\'Security.salt\',[\s\'A-z0-9]*\);)/' , $contents , $match )) {
2008-05-30 11:40:08 +00:00
$string = Security :: generateAuthKey ();
2011-12-16 06:52:07 +00:00
$result = str_replace ( $match [ 0 ], " \t " . 'Configure::write(\'Security.salt\', \'' . $string . '\');' , $contents );
2008-05-30 11:40:08 +00:00
if ( $File -> write ( $result )) {
return true ;
}
return false ;
}
2008-09-08 20:33:48 +00:00
return false ;
2008-05-30 11:40:08 +00:00
}
2009-07-24 19:18:37 +00:00
2010-10-18 02:38:32 +00:00
/**
* Generates and writes 'Security.cipherSeed'
*
* @ param string $path Project path
* @ return boolean Success
2012-03-03 23:55:07 +00:00
*/
2010-10-18 02:38:32 +00:00
public function securityCipherSeed ( $path ) {
2011-05-13 08:06:45 +00:00
$File = new File ( $path . 'Config' . DS . 'core.php' );
2010-10-18 02:38:32 +00:00
$contents = $File -> read ();
if ( preg_match ( '/([\s]*Configure::write\(\'Security.cipherSeed\',[\s\'A-z0-9]*\);)/' , $contents , $match )) {
2011-12-07 01:09:05 +00:00
App :: uses ( 'Security' , 'Utility' );
2010-10-18 02:38:32 +00:00
$string = substr ( bin2hex ( Security :: generateAuthKey ()), 0 , 30 );
2011-12-16 06:52:07 +00:00
$result = str_replace ( $match [ 0 ], " \t " . 'Configure::write(\'Security.cipherSeed\', \'' . $string . '\');' , $contents );
2010-10-18 02:38:32 +00:00
if ( $File -> write ( $result )) {
return true ;
2010-01-25 16:14:18 +00:00
}
return false ;
}
2010-10-18 02:38:32 +00:00
return false ;
}
2010-01-25 16:14:18 +00:00
2012-01-23 00:54:34 +00:00
/**
* Writes cache prefix using app ' s name
*
* @ param string $dir Path to project
* @ return boolean Success
*/
public function cachePrefix ( $dir ) {
$app = basename ( $dir );
$File = new File ( $dir . 'Config' . DS . 'core.php' );
$contents = $File -> read ();
if ( preg_match ( '/(\$prefix = \'myapp_\';)/' , $contents , $match )) {
$result = str_replace ( $match [ 0 ], '$prefix = \'' . $app . '_\';' , $contents );
2012-08-25 02:48:45 +00:00
return $File -> write ( $result );
2012-01-23 00:54:34 +00:00
}
return false ;
}
2008-05-30 11:40:08 +00:00
/**
* Generates and writes CAKE_CORE_INCLUDE_PATH
*
* @ param string $path Project path
2013-03-05 07:05:14 +00:00
* @ param boolean $hardCode Whether or not define calls should be hardcoded .
2008-05-30 11:40:08 +00:00
* @ return boolean Success
*/
2011-07-30 17:41:43 +00:00
public function corePath ( $path , $hardCode = true ) {
2008-05-30 11:40:08 +00:00
if ( dirname ( $path ) !== CAKE_CORE_INCLUDE_PATH ) {
2011-07-31 19:15:03 +00:00
$filename = $path . 'webroot' . DS . 'index.php' ;
if ( ! $this -> _replaceCorePath ( $filename , $hardCode )) {
2008-05-30 11:40:08 +00:00
return false ;
}
2011-07-31 19:15:03 +00:00
$filename = $path . 'webroot' . DS . 'test.php' ;
if ( ! $this -> _replaceCorePath ( $filename , $hardCode )) {
2008-05-30 11:40:08 +00:00
return false ;
}
return true ;
}
}
2009-07-24 19:18:37 +00:00
2011-07-31 19:15:03 +00:00
/**
* Replaces the __CAKE_PATH__ placeholder in the template files .
*
* @ param string $filename The filename to operate on .
* @ param boolean $hardCode Whether or not the define should be uncommented .
2011-08-19 02:31:00 +00:00
* @ return boolean Success
2011-07-31 19:15:03 +00:00
*/
protected function _replaceCorePath ( $filename , $hardCode ) {
$contents = file_get_contents ( $filename );
$root = strpos ( CAKE_CORE_INCLUDE_PATH , '/' ) === 0 ? " DS . ' " : " ' " ;
$corePath = $root . str_replace ( DS , " ' . DS . ' " , trim ( CAKE_CORE_INCLUDE_PATH , DS )) . " ' " ;
$result = str_replace ( '__CAKE_PATH__' , $corePath , $contents , $count );
if ( $hardCode ) {
$result = str_replace ( '//define(\'CAKE_CORE' , 'define(\'CAKE_CORE' , $result );
}
if ( ! file_put_contents ( $filename , $result )) {
return false ;
}
2012-09-14 17:42:25 +00:00
return ( bool ) $count ;
2011-07-31 19:15:03 +00:00
}
2008-05-30 11:40:08 +00:00
/**
2011-06-20 00:28:40 +00:00
* Enables Configure :: read ( 'Routing.prefixes' ) in / app / Config / core . php
2008-05-30 11:40:08 +00:00
*
* @ param string $name Name to use as admin routing
* @ return boolean Success
*/
2010-04-05 03:19:38 +00:00
public function cakeAdmin ( $name ) {
2011-04-17 11:13:02 +00:00
$path = ( empty ( $this -> configPath )) ? APP . 'Config' . DS : $this -> configPath ;
2010-10-18 02:38:32 +00:00
$File = new File ( $path . 'core.php' );
2008-05-30 11:40:08 +00:00
$contents = $File -> read ();
2011-02-23 16:26:43 +00:00
if ( preg_match ( '%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(]*\);)%' , $contents , $match )) {
2011-12-16 06:52:07 +00:00
$result = str_replace ( $match [ 0 ], " \n " . 'Configure::write(\'Routing.prefixes\', array(\'' . $name . '\'));' , $contents );
2008-05-30 11:40:08 +00:00
if ( $File -> write ( $result )) {
2009-10-07 04:46:13 +00:00
Configure :: write ( 'Routing.prefixes' , array ( $name ));
2008-05-30 11:40:08 +00:00
return true ;
}
}
2013-07-02 22:52:48 +00:00
return false ;
2008-05-30 11:40:08 +00:00
}
2009-07-24 19:18:37 +00:00
2009-07-01 00:44:09 +00:00
/**
2009-12-09 04:52:02 +00:00
* Checks for Configure :: read ( 'Routing.prefixes' ) and forces user to input it if not enabled
2009-07-01 00:44:09 +00:00
*
* @ return string Admin route to use
*/
2010-04-05 03:19:38 +00:00
public function getPrefix () {
2009-07-01 00:44:09 +00:00
$admin = '' ;
2009-10-07 04:46:13 +00:00
$prefixes = Configure :: read ( 'Routing.prefixes' );
if ( ! empty ( $prefixes )) {
2012-09-14 18:26:00 +00:00
if ( count ( $prefixes ) === 1 ) {
2010-03-07 22:14:13 +00:00
return $prefixes [ 0 ] . '_' ;
}
2009-11-11 14:56:35 +00:00
if ( $this -> interactive ) {
$this -> out ();
2011-03-19 17:32:35 +00:00
$this -> out ( __d ( 'cake_console' , 'You have more than one routing prefix configured' ));
2009-11-11 14:56:35 +00:00
}
2009-10-07 04:46:13 +00:00
$options = array ();
foreach ( $prefixes as $i => $prefix ) {
$options [] = $i + 1 ;
2009-11-11 14:56:35 +00:00
if ( $this -> interactive ) {
$this -> out ( $i + 1 . '. ' . $prefix );
}
2009-10-07 04:46:13 +00:00
}
2011-03-19 17:32:35 +00:00
$selection = $this -> in ( __d ( 'cake_console' , 'Please choose a prefix to bake with.' ), $options , 1 );
2009-10-07 04:46:13 +00:00
return $prefixes [ $selection - 1 ] . '_' ;
2009-07-01 00:44:09 +00:00
}
2009-11-11 14:56:35 +00:00
if ( $this -> interactive ) {
$this -> hr ();
2013-05-17 13:54:55 +00:00
$this -> out ( __d ( 'cake_console' , 'You need to enable %s in %s to use prefix routing.' ,
'Configure::write(\'Routing.prefixes\', array(\'admin\'))' ,
'/app/Config/core.php' ));
2011-03-19 17:32:35 +00:00
$this -> out ( __d ( 'cake_console' , 'What would you like the prefix route to be?' ));
2013-05-17 13:54:55 +00:00
$this -> out ( __d ( 'cake_console' , 'Example: %s' , 'www.example.com/admin/controller' ));
2012-09-14 17:42:25 +00:00
while ( ! $admin ) {
2011-03-19 17:32:35 +00:00
$admin = $this -> in ( __d ( 'cake_console' , 'Enter a routing prefix:' ), null , 'admin' );
2009-11-11 14:56:35 +00:00
}
if ( $this -> cakeAdmin ( $admin ) !== true ) {
2013-05-17 13:54:55 +00:00
$this -> out ( __d ( 'cake_console' , '<error>Unable to write to</error> %s.' , '/app/Config/core.php' ));
$this -> out ( __d ( 'cake_console' , 'You need to enable %s in %s to use prefix routing.' ,
'Configure::write(\'Routing.prefixes\', array(\'admin\'))' ,
'/app/Config/core.php' ));
2013-07-01 12:15:54 +00:00
return $this -> _stop ();
2009-11-11 14:56:35 +00:00
}
return $admin . '_' ;
2009-07-01 00:44:09 +00:00
}
2009-11-11 14:56:35 +00:00
return '' ;
2009-07-01 00:44:09 +00:00
}
2009-07-24 19:18:37 +00:00
2008-05-30 11:40:08 +00:00
/**
2010-10-13 02:55:19 +00:00
* get the option parser .
2008-05-30 11:40:08 +00:00
*
2010-10-13 02:55:19 +00:00
* @ return ConsoleOptionParser
2008-05-30 11:40:08 +00:00
*/
2010-10-13 02:55:19 +00:00
public function getOptionParser () {
$parser = parent :: getOptionParser ();
return $parser -> description (
2011-03-19 17:32:35 +00:00
__d ( 'cake_console' , 'Generate a new CakePHP project skeleton.' )
2010-10-13 02:55:19 +00:00
) -> addArgument ( 'name' , array (
2011-03-19 17:32:35 +00:00
'help' => __d ( 'cake_console' , 'Application directory to make, if it starts with "/" the path is absolute.' )
2010-10-17 23:01:44 +00:00
)) -> addOption ( 'empty' , array (
2012-02-07 17:35:12 +00:00
'boolean' => true ,
2011-03-19 17:32:35 +00:00
'help' => __d ( 'cake_console' , 'Create empty files in each of the directories. Good if you are using git' )
2013-05-29 13:41:57 +00:00
)) -> addOption ( 'theme' , array (
2013-05-29 13:49:12 +00:00
'short' => 't' ,
2013-05-29 13:41:57 +00:00
'help' => __d ( 'cake_console' , 'Theme to use when baking code.' )
2010-10-18 02:38:32 +00:00
)) -> addOption ( 'skel' , array (
2011-05-31 03:02:39 +00:00
'default' => current ( App :: core ( 'Console' )) . 'Templates' . DS . 'skel' ,
'help' => __d ( 'cake_console' , 'The directory layout to use for the new application skeleton. Defaults to cake/Console/Templates/skel of CakePHP used to create the project.' )
2010-10-13 02:55:19 +00:00
));
2008-05-30 11:40:08 +00:00
}
2011-04-17 16:03:43 +00:00
}