sidlerbiz / todo-bundle
提供处理简单待办事项列表的可能性
dev-master
2019-02-10 19:39 UTC
Requires
- php: ~7.1
- doctrine/doctrine-bundle: ~1.6
- symfony/config: ~3.4||~4.0
- symfony/dependency-injection: ~3.4||~4.0
- symfony/form: ~3.4||~4.0
- symfony/http-foundation: ~3.4||~4.0
- symfony/http-kernel: ~3.4||~4.0
- symfony/routing: ~3.4||~4.0
- symfony/validator: ~3.4||~4.0
This package is auto-updated.
Last update: 2024-09-11 14:43:26 UTC
README
安装
步骤 1: 插件上传
打开控制台并进入项目目录。运行以下命令以加载此插件的最新稳定版本。
composer require neo/todo-bundle
此命令表示已经安装并全局可用Composer。
步骤 2: 连接插件
下一步是将该插件添加到app/AppKernel.php中注册的插件列表中,以启用该插件。
<?php // config/bundles.php return [ // ... Neo\Bundle\TodoBundle\NeoTodoBundle::class => ['all' => true], ];
配置
在开始使用插件之前,需要进行预配置。
neo_todo: entity_name: Acme\Entity\Todo
使用
创建基于特质的实体
<?php namespace Acme\Entity; use Doctrine\ORM\Mapping as ORM; use Neo\Bundle\TodoBundle\Entity\TodoEntityInterface; use Neo\Bundle\TodoBundle\Entity\TodoEntityTrait; /** * @ORM\Entity() * @ORM\HasLifecycleCallbacks() */ class Todo implements TodoEntityInterface { use TodoEntityTrait; /** * @var int * * @ORM\Column(name="id", type="integer") * @ORM\Id() * @ORM\GeneratedValue(strategy="AUTO") */ private $id; // ... }
使用待办事项列表管理服务
<?php /** @var $todoService \Neo\Bundle\TodoBundle\Service\TodoService*/ // get instance $entity = $todoService->getById('15'); // get instances list $todoService->getList(); // change Todo status $todoService->changeStatus('15', true); // Remove todo $todoService->remove('15'); // create/update instance $todoService->save($entity); // create/update instances list $todoService->saveList([$entity]);
使用表单
<?php class CreateTodoType extends \Neo\Bundle\TodoBundle\FormType\AbstractCreateTodoType { public function configureOptions(\Symfony\Component\OptionsResolver\OptionsResolver $resolver) { $resolver->setDefaults([ 'data_class' => 'Acme\Entity\Todo', ]); } } class EditTodoType extends \Neo\Bundle\TodoBundle\FormType\AbstractEditTodoType { public function configureOptions(\Symfony\Component\OptionsResolver\OptionsResolver $resolver) { $resolver->setDefaults([ 'data_class' => 'Acme\Entity\Todo', ]); } }