Skip to content

Commit e3ebbaf

Browse files
author
Samuel Akopyan
committed
Changes in syntaxt of array
1 parent 2403f40 commit e3ebbaf

File tree

2 files changed

+51
-8
lines changed

2 files changed

+51
-8
lines changed

framework/console/CCacheClearCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ public static function handle($param = '')
4242
if (CConfig::get('cache.db.path') == '') {
4343
$output .= CConsole::redbg("Config value 'cache.db.path' is not defined. Check your configuration file.") . PHP_EOL;
4444
}else{
45-
$result = CFile::emptyDirectory(CConfig::get('cache.db.path'), array('index.html'));
45+
$result = CFile::emptyDirectory(CConfig::get('cache.db.path'), ['index.html']);
4646
$output .= 'DB cache ' . ($result ? 'successfully cleaned' : 'error');
4747
}
4848
}
4949
if($param == 'css' || $param == 'all'){
5050
if (CConfig::get('compression.css.path') == '') {
5151
$output .= CConsole::redbg("Config value 'compression.css.path' is not defined. Check your configuration file.") . PHP_EOL;
5252
}else{
53-
$result = CFile::emptyDirectory(CConfig::get('compression.css.path'), array('index.html'));
53+
$result = CFile::emptyDirectory(CConfig::get('compression.css.path'), ['index.html']);
5454
$output .= 'CSS cache ' . ($result ? 'successfully cleaned' : 'error');
5555
}
5656
}
5757
if($param == 'js' || $param == 'all'){
5858
if (CConfig::get('compression.js.path') == '') {
5959
$output .= CConsole::redbg("Config value 'compression.js.path' is not defined. Check your configuration file.") . PHP_EOL;
6060
}else{
61-
$result = CFile::emptyDirectory(CConfig::get('compression.js.path'), array('index.html'));
61+
$result = CFile::emptyDirectory(CConfig::get('compression.js.path'), ['index.html']);
6262
$output .= 'JS cache ' . ($result ? 'successfully cleaned' : 'error');
6363
}
6464
}

framework/console/CMakeControllerCommand.php

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,64 @@ public static function handle($param = '')
2929
$output = '';
3030

3131
if (empty($param)) {
32-
$output .= CConsole::redbg("No model name is defined. Type make:controller -h or --help").PHP_EOL;
32+
$output .= CConsole::redbg("No controller name is defined. Type make:controller -h or --help").PHP_EOL;
3333
}
3434
elseif ($param === '-h' || $param === '--help') {
3535
$output .= CConsole::yellow("Usage:") . PHP_EOL;
36-
$output .= " make:controller [model]\t Create a new controller class". PHP_EOL;
37-
$output .= " \t\t\t\t[model] - Generate a resource controller for the given model.". PHP_EOL;
36+
$output .= " make:controller\t[controller]\tCreate a new controller class". PHP_EOL;
37+
$output .= " \t\t\t[model] -ar\tGenerate a resource controller for the given model.". PHP_EOL;
3838
}
3939
elseif (CValidator::isVariable($param)) {
4040
// TODO: create controller
41+
//die($param);
42+
43+
$controllerFile = $param.'.php';
44+
$controllerClass = str_ireplace('Controller', '', $param).'Controller';
45+
$self = '$this';
46+
47+
$content = "<?php
48+
/**
49+
* {$controllerClass} controller
50+
*
51+
* PUBLIC: PRIVATE
52+
* ----------- ------------------
53+
* __construct
54+
* indexAction
55+
*
56+
*/
57+
58+
class {$controllerClass} extends CController
59+
{
60+
/**
61+
* Class default constructor
62+
*/
63+
public function __construct()
64+
{
65+
parent::__construct();
66+
67+
// set backend mode
68+
// Website::setBackend();
69+
// set backend mode
70+
// Website::setFrontend();
71+
}
72+
73+
/**
74+
* Controller default action handler
75+
*/
76+
public function indexAction()
77+
{
78+
// {$self}->_view->render(\'{$param}/index\');
79+
}
80+
}
81+
";
82+
CFile::writeToFile($controllerFile, $content, 'w');
83+
$output .= CConsole::green("Controller $param has been successfully created.").PHP_EOL;
4184
}
4285
else {
4386
if (!CValidator::isVariable($param)){
44-
$output .= CConsole::redbg("The model name must be a valid controller name (alphanumeric, starts with letter and can contain an underscore)! Please re-enter.").PHP_EOL;
87+
$output .= CConsole::redbg("The controller name must be a valid controller name (alphanumeric, starts with letter and can contain an underscore)! Please re-enter.").PHP_EOL;
4588
} else {
46-
$output .= CConsole::redbg("No model name is defined or wrong parameters. Type make:controller -h or --help").PHP_EOL;
89+
$output .= CConsole::redbg("No controller name is defined or wrong parameters. Type make:controller -h or --help").PHP_EOL;
4790
}
4891
}
4992

0 commit comments

Comments
 (0)