Created
November 16, 2015 08:39
-
-
Save wisaruthk/7c2446bd7849f57e68d5 to your computer and use it in GitHub Desktop.
ตัวอย่าง กำหนด response เป็น json สำหรับ controller ที่ระบุ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function behaviors() { | |
$behaviors = parent::behaviors(); | |
$behaviors['authenticator'] = [ | |
'class' => \yii\filters\auth\HttpBasicAuth::className(), | |
'only' => ['hi','token-log-in', 'log-out', | |
'list-template-data', | |
'download-template-data'], | |
]; | |
$behaviors['response'] = [ | |
'class' => 'yii\filters\ContentNegotiator', | |
'formats' => [ | |
'application/json' => Response::FORMAT_JSON, | |
], | |
]; | |
//$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON; | |
return $behaviors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment