承接 admad/cakephp-sequence 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

admad/cakephp-sequence

最新稳定版本:4.0.1

Composer 安装命令:

composer require admad/cakephp-sequence

包简介

Sequence plugin for CakePHP to maintain ordered list of records

README 文档

README

Build Status Coverage Total Downloads License

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.

统计信息

  • 总下载量: 459.42k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 46
  • 点击次数: 1
  • 依赖项目数: 8
  • 推荐数: 0

GitHub 信息

  • Stars: 45
  • Watchers: 3
  • Forks: 16
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-13