{"_id":"5dbfcb4fc11b1e0060b8bb47","githubsync":"","user":"552342f6e20da719000e7925","project":"55227389b4a0de0d00de7e28","category":{"_id":"5dbfcb4fc11b1e0060b8bb1e","__v":1,"pages":["5dbfcb4fc11b1e0060b8bb3e","5dbfcb4fc11b1e0060b8bb3f","5dbfcb4fc11b1e0060b8bb40","5dbfcb4fc11b1e0060b8bb41","5dbfcb4fc11b1e0060b8bb42","5dbfcb4fc11b1e0060b8bb43","5dbfcb4fc11b1e0060b8bb44","5dbfcb4fc11b1e0060b8bb45","5dbfcb4fc11b1e0060b8bb46","5dbfcb4fc11b1e0060b8bb47","5dbfcb4fc11b1e0060b8bb48","5dbfcb4fc11b1e0060b8bb49","5dbfcb4fc11b1e0060b8bb4a","5dbfcb4fc11b1e0060b8bb4b"],"project":"55227389b4a0de0d00de7e28","version":"5dbfcb4fc11b1e0060b8bb58","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-09T09:27:58.538Z","from_sync":false,"order":2,"slug":"_-1","title":"アドオン開発"},"version":{"_id":"5dbfcb4fc11b1e0060b8bb58","__v":0,"project":"55227389b4a0de0d00de7e28","forked_from":"5544d76ad8833c0d00582801","createdAt":"2015-05-02T13:55:54.059Z","releaseDate":"2015-05-02T13:55:54.059Z","categories":["5dbfcb4fc11b1e0060b8bb1c","5dbfcb4fc11b1e0060b8bb1d","5dbfcb4fc11b1e0060b8bb1e","5dbfcb4fc11b1e0060b8bb1f","5dbfcb4fc11b1e0060b8bb20"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"4.9.0","version":"4.9"},"__v":1,"metadata":{"title":"","description":"","image":[]},"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-13T02:42:53.855Z","link_external":false,"link_url":"","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]