mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 15:39:53 +00:00
Updating Bake to create admin route in core.php if not already set and admin routing option is used.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3669 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
8b23234b53
commit
3d47887211
1 changed files with 102 additions and 63 deletions
|
@ -678,8 +678,20 @@ class Bake {
|
|||
if(defined('CAKE_ADMIN')) {
|
||||
$admin = CAKE_ADMIN . '_';
|
||||
} else {
|
||||
$adminRoute = '';
|
||||
$this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
|
||||
$this->stdout('What would you like the admin route to be?');
|
||||
$this->stdout('Example: www.example.com/admin/controller');
|
||||
while ($adminRoute == '') {
|
||||
$adminRoute = $this->getInput("What would you like the admin route to be?", null, 'admin');
|
||||
}
|
||||
if($this->__addAdminRoute($adminRoute) !== true){
|
||||
$this->stdout('Unable to write to /app/config/core.php.');
|
||||
$this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
|
||||
exit();
|
||||
} else {
|
||||
$admin = $adminRoute . '_';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoScaffold) == 'yes') {
|
||||
|
@ -1048,8 +1060,20 @@ class Bake {
|
|||
if(defined('CAKE_ADMIN')) {
|
||||
$admin = CAKE_ADMIN.'_';
|
||||
} else {
|
||||
$adminRoute = '';
|
||||
$this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
|
||||
exit;
|
||||
$this->stdout('What would you like the admin route to be?');
|
||||
$this->stdout('Example: www.example.com/admin/controller');
|
||||
while ($adminRoute == '') {
|
||||
$adminRoute = $this->getInput("What would you like the admin route to be?", null, 'admin');
|
||||
}
|
||||
if($this->__addAdminRoute($adminRoute) !== true){
|
||||
$this->stdout('Unable to write to /app/config/core.php.');
|
||||
$this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
|
||||
exit();
|
||||
} else {
|
||||
$admin = $adminRoute . '_';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2278,6 +2302,21 @@ class Bake {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function __addAdminRoute($name){
|
||||
$file = file_get_contents(CONFIGS.'core.php');
|
||||
if (preg_match('%([/\\t\\x20]*define\\(\'CAKE_ADMIN\',[\\t\\x20\'a-z]*\\);)%', $file, $match)) {
|
||||
$result = str_replace($match[0], 'define(\'CAKE_ADMIN\', \''.$name.'\');', $file);
|
||||
|
||||
if(file_put_contents(CONFIGS.'core.php', $result)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
} |