admad/cakephp-sequence
Composer 安装命令:
composer require admad/cakephp-sequence
包简介
Sequence plugin for CakePHP to maintain ordered list of records
README 文档
README
Installation
Install this plugin into your CakePHP application using composer:
composer require admad/cakephp-sequence
Then load the plugin by running CLI command:
./bin/cake plugin load ADmad/Sequence
How it works
SequenceBehavior provided by this plugin maintains a contiguous sequence of
integers in a selected column, for records in a table (optionally with grouping)
when adding, editing (including moving groups) or deleting records.
Usage
Add the SequenceBehavior for your table and viola:
$this->addBehavior('ADmad/Sequence.Sequence');
You can customize various options as shown:
$this->addBehavior('ADmad/Sequence.Sequence', [ 'sequenceField' => 'position', // Field to use to store integer sequence. Default "position". 'scope' => ['group_id'], // Array of field names to use for grouping records. Default []. 'startAt' => 1, // Initial value for sequence. Default 1. ]);
Now whenever a new record is added its position field will be automatically
set to current largest value in sequence plus one.
When editing records you can set the position to a new value and the position of other records in the list will be automatically updated to maintain proper sequence.
When doing a find on the table an order clause is automatically added to the query to order by the position field if an order clause has not already been set.
Methods
moveUp(\Cake\Datasource\EntityInterface $entity)
Move up record by one position:
$modelObject->moveUp($entity);
moveDown(\Cake\Datasource\EntityInterface $entity)
Move down record by one position:
$modelObject->moveDown($entity);
setOrder(array $record)
Set order for list of records provided. Records can be provided as array of
entities or array of associative arrays like [['id' => 1], ['id' => 2]] or
array of primary key values like [1, 2].
Acknowledgement
Shout out to @neilcrookes for his wonderful Sequence Behavior for CakePHP 1.3 which was the inspiration for this plugin.
admad/cakephp-sequence 适用场景与选型建议
admad/cakephp-sequence 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 515.42k 次下载、GitHub Stars 达 45, 最近一次更新时间为 2015 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「orm」 「cakephp」 「list」 「sequence」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 admad/cakephp-sequence 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 admad/cakephp-sequence 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 admad/cakephp-sequence 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Easily provide front-end sorting controls for SilverStripe lists
Kinikit - PHP Application development framework MVC component
A block to display a list of links to child pages, or pages in current level
PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2
Adjacency List’ed Closure Table database design pattern implementation for Laravel. Includes restore of tree
统计信息
- 总下载量: 515.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 46
- 点击次数: 36
- 依赖项目数: 8
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-13