{"_id":"5544d76bd8833c0d0058282d","user":"552342f6e20da719000e7925","project":"55227389b4a0de0d00de7e28","category":{"_id":"5544d76ad8833c0d00582804","__v":1,"pages":["5544d76bd8833c0d00582824","5544d76bd8833c0d00582825","5544d76bd8833c0d00582826","5544d76bd8833c0d00582827","5544d76bd8833c0d00582828","5544d76bd8833c0d00582829","5544d76bd8833c0d0058282a","5544d76bd8833c0d0058282b","5544d76bd8833c0d0058282c","5544d76bd8833c0d0058282d","5544d76bd8833c0d0058282e","5544d76bd8833c0d0058282f","5544d76bd8833c0d00582830","5544d76bd8833c0d00582831"],"project":"55227389b4a0de0d00de7e28","version":"5544d76ad8833c0d00582801","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-09T09:27:58.538Z","from_sync":false,"order":2,"slug":"_-1","title":"アドオン開発"},"version":{"_id":"5544d76ad8833c0d00582801","__v":1,"project":"55227389b4a0de0d00de7e28","forked_from":"55227389b4a0de0d00de7e2b","createdAt":"2015-05-02T13:55:54.059Z","releaseDate":"2015-05-02T13:55:54.059Z","categories":["5544d76ad8833c0d00582802","5544d76ad8833c0d00582803","5544d76ad8833c0d00582804","5544d76ad8833c0d00582805","5544d76ad8833c0d00582806"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"4.0.0","version":"4.0"},"__v":1,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-13T02:42:53.855Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":9,"body":"アドオンを使用して新しいエンティティーを持つAPIを拡張する方法;\n\n1. アドオンディレクトリに`Tygh/Api/Entities`サブディレクトリを作成\n2. `Tygh/Api/Entities` ディレクトリに新しいエンティティーを含んだファイルを作成(例、Things.php)\n3. このファイルでは、ネームスペース`Tygh\\Api\\Entities` の`Api\\Entity` クラスから受け継がれた同じ名前のクラスを定義可能です。\n4. このクラスは4つの必須メソッド全てを実装する必要があります(CRUD)。\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"基本的なAPIテンプレート\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nnamespace Tygh\\\\Api\\\\Entities;\\n\\nuse Tygh\\\\Api\\\\AEntity;\\nuse Tygh\\\\Api\\\\Response;\\n\\nclass Things extends AEntity\\n{\\n    public function index($id = '', $params = array())\\n    {\\n        return array(\\n            'status' => Response::STATUS_OK,\\n            'data' => array()\\n        );\\n    }\\n\\n    public function create($params)\\n    {\\n        return array(\\n            'status' => Response::STATUS_CREATED,\\n            'data' => array()\\n        );\\n    }\\n\\n    public function update($id, $params)\\n    {\\n        return array(\\n            'status' => Response::STATUS_OK,\\n            'data' => array()\\n        );\\n    }\\n\\n    public function delete($id)\\n    {\\n        return array(\\n            'status' => Response::STATUS_NO_CONTENT,\\n        );\\n    }\\n}\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"extending-api","type":"basic","title":"APIの拡張"}
アドオンを使用して新しいエンティティーを持つAPIを拡張する方法; 1. アドオンディレクトリに`Tygh/Api/Entities`サブディレクトリを作成 2. `Tygh/Api/Entities` ディレクトリに新しいエンティティーを含んだファイルを作成(例、Things.php) 3. このファイルでは、ネームスペース`Tygh\Api\Entities` の`Api\Entity` クラスから受け継がれた同じ名前のクラスを定義可能です。 4. このクラスは4つの必須メソッド全てを実装する必要があります(CRUD)。 [block:api-header] { "type": "basic", "title": "基本的なAPIテンプレート" } [/block] [block:code] { "codes": [ { "code": "<?php\n\nnamespace Tygh\\Api\\Entities;\n\nuse Tygh\\Api\\AEntity;\nuse Tygh\\Api\\Response;\n\nclass Things extends AEntity\n{\n public function index($id = '', $params = array())\n {\n return array(\n 'status' => Response::STATUS_OK,\n 'data' => array()\n );\n }\n\n public function create($params)\n {\n return array(\n 'status' => Response::STATUS_CREATED,\n 'data' => array()\n );\n }\n\n public function update($id, $params)\n {\n return array(\n 'status' => Response::STATUS_OK,\n 'data' => array()\n );\n }\n\n public function delete($id)\n {\n return array(\n 'status' => Response::STATUS_NO_CONTENT,\n );\n }\n}", "language": "php" } ] } [/block]