codifico / actions
动作组件
dev-master
2015-10-28 07:40 UTC
Requires
- php: >=5.4
- symfony/form: *
- symfony/http-foundation: *
Requires (Dev)
- phpspec/phpspec: ~2.0
This package is not auto-updated.
Last update: 2024-09-14 18:25:58 UTC
README
基于组件的常见动作耦合
允许您快速创建 CRUD 动作。
安装
php composer.phar require codifico/actions:dev-master
用法
准备您的仓库以便能够使用 动作
class MyRepository implements ActionRepository { //(...) } ### Basic If you want to use the basic version (based on Form and HttpFoundation Components), create your own classes: ```php use Codifico\Component\Actions\Action\Basic\CreateAction; use Codifico\Component\Actions\Action\Basic\IndexAction; use Codifico\Component\Actions\Action\Basic\RemoveAction; use Codifico\Component\Actions\Action\Basic\UpdateAction; class MyEntityCreateAction extends CreateAction { //(...) } class MyEntityIndexAction extends IndexAction { //(...) } class MyEntityRemoveAction extends RemoveAction { //(...) } class MyEntityUpdateAction extends UpdateAction { //(...) }
最后但同样重要的是,使用它们
//Create: $create = new MyEntityCreateAction($repository, $formFactory, $myEntityType); $create->execute(); //Index: $index = new MyEntityIndexAction($repository); $index->setCriteria($criteria)->execute(); //Remove: $remove = new MyEntityRemoveAction($repository); $remove->setObject($object)->execute(); //Update: $update = new MyEntityUpdateAction($formFactory, $myEntityType); $update->setObject($object)->execute();
自定义
否则,您可能想使用接口
- Codifico\Component\Actions\Action\CreateAction
- Codifico\Component\Actions\Action\RemoveAction
- Codifico\Component\Actions\Action\UpdateAction
甚至
- Codifico\Component\Actions\Action\Action
版权
版权(c)2015 Marcin Dryka(drymek)。有关详细信息,请参阅 LICENSE。