yii2

2016-04-23 9 views
0

URLにextrapatternを作成:http://localhost/eg_integration/api/web/v1/devices/cacf090690d9dab14df06219ac36b3cd/registrations/pass.usa.gift?passesUpdatedSince=1232yii2

ホスト:http://localhost/eg_integration/api/web/v1 コントローラ:デバイス Contantを用語:登録、passesUpdatedSince

URLルールコード:extrapatternでこのURLを処理するために、ホット

'class' => 'yii\rest\UrlRule', 
            'controller' => 'v1/devices', 
            'pluralize' => false, 
            'extraPatterns' => [ 
    'GET registration' => 'getserialnumber', 
] 

答えて

0

URLが一定であるとすれば、私は

'GET cacf090690d9dab14df06219ac36b3cd/registrations/pass.usa.gift' => 'getserialnumber', 

は、その後、あなたのdeviceControllerにクエリパラメータを取得:

public function actionGetserialnumber() { 
    ... 
    $value = Yii::$app->getRequest()->getQueryParam('passesUpdatedSince', $defaultValue) 
    ... 
} 
このようなルールトン