Skip to content

Commit

Permalink
Merge pull request #31 from shinichi-takahashi/router
Browse files Browse the repository at this point in the history
α
  • Loading branch information
Shinichi Takahashi committed Jan 23, 2015
2 parents e96c4c1 + a20f716 commit 9e55faa
Show file tree
Hide file tree
Showing 583 changed files with 10,261 additions and 10,029 deletions.
8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,13 @@
"satooshi/php-coveralls": "dev-master",
"phpunit/phpunit": "3.7.*",
"phing/phing": "2.*"
<<<<<<< HEAD
},
"autoload": {
"psr-0": {
"Eccube": "data/"
}
=======
>>>>>>> e96c4c175cdfde99ea5b44f68bd09ada46bac4c3
}
}
113 changes: 113 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions data/Eccube/Api/AbstractApi.php
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);
}

}
Loading

0 comments on commit 9e55faa

Please sign in to comment.