runroom-packages/sortable-behavior-bundle
Composer 安装命令:
composer require runroom-packages/sortable-behavior-bundle
包简介
Provides a way to sort your admin listing
README 文档
README
This bundle gives the ability to define sortable entities and to be able to sort the using Sonata Backoffice. It is inspired on: pixSortableBehaviorBundle.
Installation
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
composer require runroom-packages/sortable-behavior-bundle
Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles in config/bundles.php file of your project:
// config/bundles.php return [ // ... Runroom\SortableBehaviorBundle\RunroomSortableBehaviorBundle::class => ['all' => true], ];
Usage
This bundle checks if you are using Gedmo Sortable to handle the sort order of your entities, if not, it will use the default ORM implementation, where you will need to add entities on the configuration of the bundle manually. If you are using Gedmo, and don't want to change the default field name position, you don't need to configure anything for the bundle.
We provide a trait, so you can easily add the position field with the Gedmo configuration on each entity you want to be able to sort:
# src/Entity/Example.php namespace App\Entity; use Runroom\SortableBehaviorBundle\Behaviors\Sortable; class Example { use Sortable; // ... rest of your class }
And then, on your admin class, you can add the SortableAdminTrait trait to be able to sort the entities on the list view:
# src/Admin/ExampleAdmin.php namespace App\Admin; use Runroom\SortableBehaviorBundle\Admin\SortableAdminTrait; use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Datagrid\ListMapper; class ExampleAdmin extends AbstractAdmin { use SortableAdminTrait; protected function configureListFields(ListMapper $list): void { $list // ... rest of your list fields ->add(ListMapper::NAME_ACTIONS, ListMapper::TYPE_ACTIONS, [ 'actions' => [ // ... rest of your actions 'move' => [ 'template' => '@RunroomSortableBehavior/sort.html.twig', ], ], ]); } }
And that's all, you should now see the sort buttons on the list view of your admin class.
Configuration
# config/packages/runroom_sortable_behavior.yaml runroom_sortable_behavior: # position_handler can be any service id that implements the PositionHandlerInterface position_handler: Runroom\SortableBehaviorBundle\Service\GedmoPositionHandler # or Runroom\SortableBehaviorBundle\Service\ORMPositionHandler if gedmo is not found position_field: default: position # Default field name for the position # Only needed when not using Gedmo entities: App\Entity\Foobar: order App\Entity\Baz: rang # Only needed when not using Gedmo sortable_groups: entities: App\Entity\Baz: [group]
Use a draggable list instead of up/down buttons
In order to use a draggable list instead of up/down buttons, change the template in the move action to @RunroomSortableBehavior/sort_drag_drop.html.twig.
protected function configureListFields(ListMapper $list): void { $list // ... rest of your list fields ->add(ListMapper::NAME_ACTIONS, ListMapper::TYPE_ACTIONS, [ 'actions' => [ // ... rest of your actions 'move' => [ 'template' => '@RunroomSortableBehavior/sort_drag_drop.html.twig', 'enable_top_bottom_buttons' => true, // optional ], ], ]); }
Contribute
The sources of this package are contained in the Runroom monorepo. We welcome contributions for this package on runroom/runroom-packages.
License
This bundle is under the MIT license.
runroom-packages/sortable-behavior-bundle 适用场景与选型建议
runroom-packages/sortable-behavior-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.35M 次下载、GitHub Stars 达 11, 最近一次更新时间为 2020 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「admin」 「sonata」 「sortable」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 runroom-packages/sortable-behavior-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 runroom-packages/sortable-behavior-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 runroom-packages/sortable-behavior-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Sonata Extra admin features
Easily provide front-end sorting controls for SilverStripe lists
ACL list filtering for SonataAdmin
2lenet/EasyAdminPlusBundle
Sortable models for Laravel Eloquent ORM.
Analysis module for finding problematical shop data.
统计信息
- 总下载量: 1.35M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 33
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-16