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:
parent
21fdd5d453
commit
80b1a61a12
|
@ -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
|
|
@ -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:
|
||||
*
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue