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

View File

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

View File

@ -19,14 +19,14 @@ class LoginForm extends Model
*/ */
public function rules() public function rules()
{ {
return array( return [
// username and password are both required // username and password are both required
array('username, password', 'required'), ['username, password', 'required'],
// password is validated by validatePassword() // password is validated by validatePassword()
array('password', 'validatePassword'), ['password', 'validatePassword'],
// rememberMe must be a boolean value // 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 $password;
public $authKey; public $authKey;
private static $users = array( private static $users = [
'100' => array( '100' => [
'id' => '100', 'id' => '100',
'username' => 'admin', 'username' => 'admin',
'password' => 'admin', 'password' => 'admin',
'authKey' => 'test100key', 'authKey' => 'test100key',
), ],
'101' => array( '101' => [
'id' => '101', 'id' => '101',
'username' => 'demo', 'username' => 'demo',
'password' => 'demo', 'password' => 'demo',
'authKey' => 'test101key', 'authKey' => 'test101key',
), ],
); ];
public static function findIdentity($id) public static function findIdentity($id)
{ {