Add CakePHP Crud plugin to the API

I wish I knew about this plugin months ago.

By default PDO and CakePHP cast int as string.  This prevents me
from using `<input type="number">`, as the modle that the input
is bound to is actually a string, not an int.

Crud by default casts int back to int via ApiTransformationListener

It also has a bunch of other features which makes the life of a
REST / CRUD developer easier.
This commit is contained in:
Kyle Johnson 2015-02-25 10:28:24 -05:00
parent 21fdd5d453
commit 80b1a61a12
4 changed files with 21 additions and 2 deletions

4
.gitmodules vendored Normal file
View File

@ -0,0 +1,4 @@
[submodule "web/api/app/Plugin/Crud"]
path = web/api/app/Plugin/Crud
url = git://github.com/FriendsOfCake/crud.git
branch = master

View File

@ -69,7 +69,7 @@ Cache::config('default', array('engine' => 'File'));
* CakePlugin::load('DebugKit'); //Loads a single plugin named DebugKit
*
*/
CakePlugin::load('Crud');
/**
* You can attach event listeners to the request lifecycle as Dispatcher Filter. By default CakePHP bundles two filters:
*

View File

@ -18,8 +18,8 @@
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('Controller', 'Controller');
App::uses('CrudControllerTrait', 'Crud.Lib');
/**
* Application Controller
@ -31,4 +31,18 @@ App::uses('Controller', 'Controller');
* @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
*/
class AppController extends Controller {
use CrudControllerTrait;
public $components = [
'RequestHandler',
'Crud.Crud' => [
'actions' => [
'index' => 'Crud.Index',
'add' => 'Crud.Add',
'edit' => 'Crud.Edit',
'view' => 'Crud.View'
],
'listeners' => ['Api', 'ApiTransformation']
]
];
}

@ -0,0 +1 @@
Subproject commit 6faf8df67fb788351e00e9401670558cad3dab05