-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from shinichi-takahashi/router
α
- Loading branch information
Showing
583 changed files
with
10,261 additions
and
10,029 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of EC-CUBE | ||
* | ||
* Copyright(c) 2000-2014 LOCKON CO.,LTD. All Rights Reserved. | ||
* http://www.lockon.co.jp/ | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Eccube\Api; | ||
|
||
use Eccube\Page\AbstractPage; | ||
use Eccube\Common\Display; | ||
use Eccube\Common\Query; | ||
use Eccube\Common\Response; | ||
|
||
abstract class AbstractApi | ||
{ | ||
var $requestMethod; | ||
var $requestBody; | ||
var $responseStatusCode; | ||
var $responseBody; | ||
|
||
|
||
/** | ||
* Page を初期化する. | ||
* | ||
* @return void | ||
*/ | ||
public function init() | ||
{ | ||
$this->requestMethod = $this->getRequestMethod(); | ||
$this->requestBody = $this->getRequestBody(); | ||
$this->responseStatusCode = 200; | ||
} | ||
|
||
/** | ||
* Page のプロセス. | ||
* | ||
* @return void | ||
*/ | ||
public function process() | ||
{ | ||
} | ||
|
||
public function sendResponseJson () { | ||
$objDisplay = new Display(); | ||
$objDisplay->addHeader('HTTP/1.1', $this->responseStatusCode); | ||
$objDisplay->addHeader('Content-type', "application/json; charset=utf-8"); | ||
$objDisplay->addHeader('Cache-Control', ''); | ||
$objDisplay->addHeader('Pragma', ''); | ||
|
||
$objDisplay->response->body = json_encode($this->responseBody); | ||
$objDisplay->response->write(); | ||
Response::actionExit(); | ||
} | ||
|
||
/** | ||
* メソッド取得 | ||
* @return string | ||
*/ | ||
protected function getRequestMethod() { | ||
return $_SERVER['REQUEST_METHOD']; | ||
} | ||
|
||
/** | ||
* リクエストボディ取得 | ||
* @return string | ||
*/ | ||
protected function getRequestBody() { | ||
$f = fopen('php://input', 'r'); | ||
$content = stream_get_contents($f); | ||
fclose($f); | ||
// 連想配列でreturn | ||
return json_decode($content, true); | ||
} | ||
|
||
} |
Oops, something went wrong.