Merge pull request #1010 from KingYes/master

Convert to short syntax (array)
This commit is contained in:
Alexander Makarov 2013-10-18 01:37:46 -07:00
commit 65cc32344d
4 changed files with 48 additions and 48 deletions

View File

@ -13,43 +13,43 @@ class SiteController extends Controller
{
public function behaviors()
{
return array(
'access' => array(
return [
'access' => [
'class' => AccessControl::className(),
'only' => array('login', 'logout'),
'rules' => array(
array(
'actions' => array('login'),
'only' => ['login', 'logout'],
'rules' => [
[
'actions' => ['login'],
'allow' => true,
'roles' => array('?'),
),
array(
'actions' => array('logout'),
'roles' => ['?'],
],
[
'actions' => ['logout'],
'allow' => true,
'roles' => array('@'),
),
),
),
'verbs' => array(
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => array(
'logout' => array('post'),
),
),
);
'actions' => [
'logout' => ['post'],
],
],
];
}
public function actions()
{
return array(
'error' => array(
return [
'error' => [
'class' => 'yii\web\ErrorAction',
),
'captcha' => array(
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
),
);
],
];
}
public function actionIndex()
@ -63,9 +63,9 @@ class SiteController extends Controller
if ($model->load($_POST) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', array(
return $this->render('login', [
'model' => $model,
));
]);
}
}
@ -82,9 +82,9 @@ class SiteController extends Controller
Yii::$app->session->setFlash('contactFormSubmitted');
return $this->refresh();
} else {
return $this->render('contact', array(
return $this->render('contact', [
'model' => $model,
));
]);
}
}

View File

@ -20,14 +20,14 @@ class ContactForm extends Model
*/
public function rules()
{
return array(
return [
// name, email, subject and body are required
array('name, email, subject, body', 'required'),
['name, email, subject, body', 'required'],
// email has to be a valid email address
array('email', 'email'),
['email', 'email'],
// verifyCode needs to be entered correctly
array('verifyCode', 'captcha'),
);
['verifyCode', 'captcha'],
];
}
/**
@ -35,9 +35,9 @@ class ContactForm extends Model
*/
public function attributeLabels()
{
return array(
return [
'verifyCode' => 'Verification Code',
);
];
}
/**

View File

@ -19,14 +19,14 @@ class LoginForm extends Model
*/
public function rules()
{
return array(
return [
// username and password are both required
array('username, password', 'required'),
['username, password', 'required'],
// password is validated by validatePassword()
array('password', 'validatePassword'),
['password', 'validatePassword'],
// rememberMe must be a boolean value
array('rememberMe', 'boolean'),
);
['rememberMe', 'boolean'],
];
}
/**

View File

@ -9,20 +9,20 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
public $password;
public $authKey;
private static $users = array(
'100' => array(
private static $users = [
'100' => [
'id' => '100',
'username' => 'admin',
'password' => 'admin',
'authKey' => 'test100key',
),
'101' => array(
],
'101' => [
'id' => '101',
'username' => 'demo',
'password' => 'demo',
'authKey' => 'test101key',
),
);
],
];
public static function findIdentity($id)
{