Skip to content

Commit af9c39c

Browse files
author
Samuel Akopyan
committed
Implemented make:controller [controller] console command
1 parent e3ebbaf commit af9c39c

File tree

16 files changed

+606
-549
lines changed

16 files changed

+606
-549
lines changed

demos/login-system/protected/components/Bootstrap.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ class Bootstrap extends CComponent
2424
*/
2525
function __construct()
2626
{
27-
A::app()->attachEventHandler('_onBeginRequest', array($this, 'setTimeZone'));
28-
A::app()->attachEventHandler('_onBeginRequest', array($this, 'setSslMode'));
29-
A::app()->attachEventHandler('_onBeginRequest', array($this, 'setCron'));
30-
31-
A::app()->attachEventHandler('_onEndRequest', array($this, 'setLastVisitedPage'));
32-
}
33-
34-
/**
35-
* Returns the instance of object
27+
A::app()->attachEventHandler('_onBeginRequest', [$this, 'setTimeZone']);
28+
A::app()->attachEventHandler('_onBeginRequest', [$this, 'setSslMode']);
29+
A::app()->attachEventHandler('_onBeginRequest', [$this, 'setCron']);
30+
31+
A::app()->attachEventHandler('_onEndRequest', [$this, 'setLastVisitedPage']);
32+
}
33+
34+
/**
35+
* Returns the instance of object
3636
* @return current class
3737
*/
3838
public static function init()

demos/login-system/protected/controllers/AccountController.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ public function editAction()
3333
if ($cRequest->getPost('act') == 'send') {
3434

3535
// Perform account edit form validation
36-
$result = CWidget::create('CFormValidation', array(
37-
'fields' => array(
38-
//'username'=>array('title'=>'Username' 'validation'=>array('required'=>true, 'type'=>'username', 'minLength'=>4)),
39-
'password' => array('title' => 'Password', 'validation' => array('required' => true, 'type' => 'password', 'minLength' => 4)),
40-
),
41-
));
36+
$result = CWidget::create('CFormValidation', [
37+
'fields' => [
38+
'password' => ['title' => 'Password', 'validation' => ['required' => true, 'type' => 'password', 'minLength' => 4]],
39+
],
40+
]);
4241

4342
if ($result['error']) {
4443
$msg = $result['errorMessage'];
@@ -62,8 +61,8 @@ public function editAction()
6261

6362
if (!empty($msg)) {
6463
$this->_view->username = $cRequest->getPost('username', 'string');
65-
$this->_view->actionMessage = CWidget::create('CMessage', array($msgType, $msg, array('button' => true)));
66-
} else {
64+
$this->_view->actionMessage = CWidget::create('CMessage', [$msgType, $msg, ['button' => true]]);
65+
} else {
6766
$this->_view->username = $info['username'];
6867
}
6968
} else {

demos/login-system/protected/controllers/LoginController.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@ public function runAction()
4141
if ($cRequest->getPost('act') == 'send') {
4242

4343
// perform login form validation
44-
$result = CWidget::create('CFormValidation', array(
45-
'fields' => array(
46-
'username' => array('title' => 'Username', 'validation' => array('required' => true, 'type' => 'any')),
47-
'password' => array('title' => 'Password', 'validation' => array('required' => true, 'type' => 'any')),
48-
),
49-
));
50-
51-
if ($result['error']) {
44+
$result = CWidget::create(
45+
'CFormValidation',
46+
[
47+
'fields' => [
48+
'username' => ['title' => 'Username', 'validation' => ['required' => true, 'type' => 'any']],
49+
'password' => ['title' => 'Password', 'validation' => ['required' => true, 'type' => 'any']],
50+
],
51+
]
52+
);
53+
54+
if ($result['error']) {
5255
$msg = $result['errorMessage'];
5356
$msgType = 'validation';
5457
$this->_view->errorField = $result['errorField'];
@@ -66,8 +69,8 @@ public function runAction()
6669
if (!empty($msg)) {
6770
$this->_view->username = $cRequest->getPost('username', 'string');
6871
$this->_view->password = $cRequest->getPost('password', 'string');
69-
$this->_view->actionMessage = CWidget::create('CMessage', array($msgType, $msg));
70-
}
72+
$this->_view->actionMessage = CWidget::create('CMessage', [$msgType, $msg]);
73+
}
7174
}
7275
$this->_view->render('login/index');
7376
}

demos/login-system/protected/modules/setup/controllers/SetupController.php

Lines changed: 82 additions & 54 deletions
Large diffs are not rendered by default.

demos/login-system/protected/views/index/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
</article>
1010
<?php
1111
if(!CAuth::isLoggedIn()){
12-
echo CWidget::create('CMessage', array('info', 'Click <a href="login/index"><b>here</b></a> to log into the system as administrator.'));
12+
echo CWidget::create('CMessage', ['info', 'Click <a href="login/index"><b>here</b></a> to log into the system as administrator.']);
1313
}
1414
?>

demos/login-system/protected/views/login/index.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<?php
88
if(APPHP_MODE == 'demo'){
9-
echo CWidget::create('CMessage', array('info', 'To access the demo account enter<br>Username: <b>admin</b><br>Password: <b>test</b>'));
9+
echo CWidget::create('CMessage', ['info', 'To access the demo account enter<br>Username: <b>admin</b><br>Password: <b>test</b>']);
1010
}
1111
?>
1212

@@ -17,25 +17,25 @@
1717

1818
<?php
1919
// draw login form
20-
echo CWidget::create('CFormView', array(
20+
echo CWidget::create('CFormView', [
2121
'action'=>'login/run',
2222
'method'=>'post',
23-
'htmlOptions'=>array(
24-
'name'=>'frmLogin'
25-
),
26-
'fields'=>array(
27-
'act' =>array('type'=>'hidden', 'value'=>'send'),
28-
'username'=>array('type'=>'textbox', 'value'=>$username, 'title'=>'Username', 'mandatoryStar'=>false, 'htmlOptions'=>array('maxlength'=>'32', 'autocomplete'=>'off')),
29-
'password'=>array('type'=>'password', 'value'=>$password, 'title'=>'Password', 'mandatoryStar'=>false, 'htmlOptions'=>array('maxLength'=>'20')),
30-
),
31-
'buttons'=>array(
32-
'submit'=>array('type'=>'submit', 'value'=>'Login'),
33-
),
34-
'events'=>array(
35-
'focus'=>array('field'=>$errorField)
36-
),
23+
'htmlOptions' => [
24+
'name' => 'frmLogin'
25+
],
26+
'fields'=>[
27+
'act' =>['type'=>'hidden', 'value'=>'send'],
28+
'username'=>['type'=>'textbox', 'value'=>$username, 'title'=>'Username', 'mandatoryStar'=>false, 'htmlOptions'=>array('maxlength'=>'32', 'autocomplete'=>'off')],
29+
'password'=>['type'=>'password', 'value'=>$password, 'title'=>'Password', 'mandatoryStar'=>false, 'htmlOptions'=>array('maxLength'=>'20')],
30+
],
31+
'buttons' => [
32+
'submit' => ['type' => 'submit', 'value' => 'Login'],
33+
],
34+
'events' => [
35+
'focus' => ['field' => $errorField]
36+
],
3737
'return'=>true,
38-
));
38+
]);
3939
?>
4040

4141
</fieldset>

demos/login-system/templates/default/default.php

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,55 @@
1919
<header>
2020
<nav>
2121
<?php
22-
CWidget::create('CMenu', array(
23-
'items' => array(
24-
array('label' => 'Home', 'url' => 'index/index'),
25-
(CAuth::isLoggedIn() == true) ? array('label' => 'Dashboard', 'url' => 'page/dashboard') : '',
26-
(CAuth::isLoggedIn() == true) ? array('label' => 'My Account', 'url' => 'account/edit') : '',
27-
array('label' => 'Public Page #1', 'url' => 'page/public/id/1'),
28-
array('label' => 'Public Page #2', 'url' => 'page/public/id/2'),
29-
),
30-
'type' => 'horizontal',
31-
'selected' => $this->_activeMenu,
32-
'return' => false,
33-
));
34-
?>
35-
36-
<?php
37-
CWidget::create('CMenu', array(
38-
'items' => array(
39-
(CAuth::isLoggedIn() == true) ? array('label' => 'Logout', 'url' => 'login/logout') : array('label' => 'Login', 'url' => 'login/index'),
40-
),
41-
'type' => 'horizontal',
42-
'class' => 'user_menu',
43-
'selected' => $this->_activeMenu,
44-
'return' => false,
45-
));
46-
?>
22+
CWidget::create(
23+
'CMenu',
24+
[
25+
'items' => [
26+
['label' => 'Home', 'url' => 'index/index'],
27+
(CAuth::isLoggedIn() == true) ? ['label' => 'Dashboard', 'url' => 'page/dashboard'] : '',
28+
(CAuth::isLoggedIn() == true) ? ['label' => 'My Account', 'url' => 'account/edit'] : '',
29+
['label' => 'Public Page #1', 'url' => 'page/public/id/1'],
30+
['label' => 'Public Page #2', 'url' => 'page/public/id/2'],
31+
],
32+
'type' => 'horizontal',
33+
'selected' => $this->_activeMenu,
34+
'return' => false,
35+
]
36+
);
37+
?>
38+
39+
<?php
40+
CWidget::create(
41+
'CMenu',
42+
[
43+
'items' => [
44+
(CAuth::isLoggedIn() == true)
45+
? ['label' => 'Logout', 'url' => 'login/logout']
46+
: [
47+
'label' => 'Login',
48+
'url' => 'login/index'
49+
],
50+
],
51+
'type' => 'horizontal',
52+
'class' => 'user_menu',
53+
'selected' => $this->_activeMenu,
54+
'return' => false,
55+
]
56+
);
57+
?>
4758
</nav>
4859
</header>
4960
<section>
5061
<?php
51-
CWidget::create('CBreadCrumbs', array(
52-
'links' => $this->_breadCrumbs,
53-
'return' => false,
54-
));
55-
?>
56-
<?= A::app()->view->getContent(); ?>
62+
CWidget::create(
63+
'CBreadCrumbs',
64+
[
65+
'links' => $this->_breadCrumbs,
66+
'return' => false,
67+
]
68+
);
69+
?>
70+
<?= A::app()->view->getContent(); ?>
5771
</section>
5872
<footer>
5973
<p class="copyright">Copyright &copy; <?= @date('Y'); ?> Your Site</p>

demos/login-system/templates/setup/default.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,26 @@
2929
</div>
3030

3131
<?php
32-
CWidget::create('CMenu', array(
33-
'type' => 'vertical',
34-
'items' => array(
35-
array('label' => '1. ' . A::t('setup', 'General'), 'url' => 'setup/index', 'readonly' => true),
36-
array('label' => '2. ' . A::t('setup', 'Check Requirements'), 'url' => 'setup/requirements', 'readonly' => true),
37-
array('label' => '3. ' . A::t('setup', 'Database Settings'), 'url' => 'setup/database', 'readonly' => true),
38-
array('label' => '4. ' . A::t('setup', 'Administrator Account'), 'url' => 'setup/administrator', 'readonly' => true),
39-
array('label' => '5. ' . A::t('setup', 'Ready to Install'), 'url' => 'setup/ready', 'readonly' => true),
40-
array('label' => '6. ' . A::t('setup', 'Completed'), 'url' => 'setup/completed', 'readonly' => true),
41-
),
42-
'selected' => $this->_activeMenu,
43-
'return' => false,
44-
));
45-
?>
32+
CWidget::create(
33+
'CMenu',
34+
[
35+
'type' => 'vertical',
36+
'items' => [
37+
['label' => '1. '.A::t('setup', 'General'), 'url' => 'setup/index', 'readonly' => true],
38+
['label' => '2. '.A::t('setup', 'Check Requirements'), 'url' => 'setup/requirements', 'readonly' => true],
39+
['label' => '3. '.A::t('setup', 'Database Settings'), 'url' => 'setup/database', 'readonly' => true],
40+
['label' => '4. '.A::t('setup', 'Administrator Account'), 'url' => 'setup/administrator', 'readonly' => true],
41+
['label' => '5. '.A::t('setup', 'Ready to Install'), 'url' => 'setup/ready', 'readonly' => true],
42+
['label' => '6. '.A::t('setup', 'Completed'), 'url' => 'setup/completed', 'readonly' => true],
43+
],
44+
'selected' => $this->_activeMenu,
45+
'return' => false,
46+
]
47+
);
48+
?>
4649
</aside>
4750
<article>
48-
<?= A::app()->view->getContent(); ?>
51+
<?= A::app()->view->getContent(); ?>
4952
</article>
5053
</section>
5154
<footer>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
return array(
4-
// Module classes
5-
'classes' => array(
6-
'Modules\Setup\Controllers\Setup',
7-
),
8-
);
3+
return [
4+
// Module classes
5+
'classes' => [
6+
'Modules\Setup\Controllers\Setup',
7+
],
8+
];

demos/simple-blog/protected/modules/setup/views/setup/database.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212
<br>
1313

1414
<?php
15-
echo CWidget::create('CFormView', array(
15+
echo CWidget::create('CFormView', [
1616
'action' => 'setup/database',
1717
'method' => 'post',
18-
'htmlOptions' => array(
18+
'htmlOptions' => [
1919
'name' => 'frmSetup',
2020
'id' => 'frmSetup',
21-
),
21+
],
2222
'fields' => $formFields,
23-
'buttons' => array(
24-
'back' => array('type' => 'button', 'value' => A::t('setup', 'Previous'), 'htmlOptions' => array('name' => '', 'onclick' => "$(location).attr('href','setup/requirements');")),
25-
'submit' => array('type' => 'submit', 'value' => A::t('setup', 'Next'), 'htmlOptions' => array('name' => '')),
26-
),
27-
'events' => array(
28-
'focus' => array('field' => $errorField),
29-
),
23+
'buttons' => [
24+
'back' => ['type' => 'button', 'value' => A::t('setup', 'Previous'), 'htmlOptions' => ['name' => '', 'onclick' => "$(location).attr('href','setup/requirements');"]],
25+
'submit' => ['type' => 'submit', 'value' => A::t('setup', 'Next'), 'htmlOptions' => ['name' => '']],
26+
],
27+
'events' => [
28+
'focus' => ['field' => $errorField],
29+
],
3030
'return' => true,
31-
));
31+
]);
3232
?>
3333
<br>

0 commit comments

Comments
 (0)