dszczer / lister
此包已被弃用,不再维护。未建议替代包。
Symfony 2.8/3.x 列表生成器,与 Propel 2 或 Doctrine 2 兼容,可直接使用。
v0.9.22
2018-02-24 18:30 UTC
Requires
- php: ^7.0
- sensio/framework-extra-bundle: ^3.0.2||^5.0.0
- symfony/symfony: ^2.8||^3.0
Requires (Dev)
- ext-sqlite3: *
- doctrine/doctrine-bundle: ~1.3
- doctrine/orm: ~2.5
- phpdocumentor/phpdocumentor: 2.*
- phpunit/phpunit: ~5.7
- propel/propel: ~2.0@dev
- propel/propel-bundle: ~2.0@dev
This package is not auto-updated.
Last update: 2022-04-02 07:51:53 UTC
README
免责声明:文档和测试套件尚不完整。此包处于开发阶段。
需求
PHP >7.0.0
Symfony ~2.8
(Symfony ~3.0 未测试,可能可行)
Doctrine ORM ~2.0 或 Propel ORM ~2.0
(Propel ~3.0 未测试)
安装
- 通过 Composer 复制文件:
composer require dszczer/lister。 - 如有需要,放置配置文件
# app/config.yml # Full Lister Configuration lister: orm: auto # [auto, doctrine, propel]; 'auto' for auto detection, and using both of ORMs simultaneously also perpage: 25 # any integer above 0 form_name_prefix: 'lister_filters' use_csrf: true # Minimum Lister Configuration # Above values are default ones, no need to place any configuarion node
- 添加路由
# app/config/routing.yml lister: resource: "@DszczerListerBundle/Resources/config/routing.yml" type: yaml
- 在 AppKernel 中启用包
// app/AppKernel.php // ... $bundles = [ // ... new Dszczer\ListerBundle\DszczerListerBundle() ]; // ...
基本用法
<?php // src/AppBundle/Controller/AppController.php public function listAction(Request $request) { // use factory to create new lister $list = $this->get('lister.factory')->createList( '\\Full\\Class\\Name\\Of\\ModelCriteria\\Query\\Object', // full class name of Propel query object 'exampleOneList', // unique list identifier 'lister' // translation domain ); // create some basic list // NOTICE: order of adding items does matter! $list ->addField('id', 'Id') ->addField('username', 'Username', true, Filter::TYPE_TEXT) ->addField('email', 'E-mail', true, Filter::TYPE_TEXT); return $this->render( 'AppBundle:User:list.html.twig', ['list' => $list->apply($request)] ); }
{# src/AppBundle/Resources/views/User/list.html.twig #} {{ lister_filters(list) }} {{ lister_body(list) }} {{ lister_pagination(list) }}