定制 muffin/orderly 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

muffin/orderly

最新稳定版本:3.0.1

Composer 安装命令:

composer require muffin/orderly

包简介

Default ordering (behavior) for CakePHP

README 文档

README

Build Status Coverage Total Downloads License

Allows setting default order for your tables.

Install

Using Composer:

composer require muffin/orderly

Then load the plugin using the console command:

bin/cake plugin load Muffin/Orderly

What is does

Orderly allow you to set default ORDER clause for your table's SELECT queries.

Usage

Here's how you can add the Orderly behavior for your tables:

// By default orders by display field of table.
$this->addBehavior('Muffin/Orderly.Orderly');

// Default ordering using specified field.
$this->addBehavior('Muffin/Orderly.Orderly', ['order' => $this->aliasField('field_name')]);

Value for order key can any valid value that \Cake\ORM\Query::orderBy() takes. The default order clause will only be applied to the primary query and when no custom order clause has already been set for the query.

You can also configure the behavior to apply the default order based on required condition using callback option. The order will be applied if callback returns true:

$this->addBehavior('Muffin/Orderly.Orderly', [
    'order' => ['Alias.field_name' => 'DESC'],
    'callback' => function (\Cake\ORM\Query $query, \ArrayObject $options, bool $primary) {
        //return a boolean
    }
]);

The behavior can also be configured with multiple orders which are applied based on return value of their respective callbacks:

$this->addBehavior('Muffin/Orderly.Orderly', [
    [
        'order' => ['Alias.field_name' => 'DESC'],
        'callback' => function (\Cake\ORM\Query $query, \ArrayObject $options, bool $primary) {
            //return a boolean
        }
    ],
    [
        'order' => ['Alias.another_field'],
        'callback' => function (\Cake\ORM\Query $query, \ArrayObject $options, bool $primary) {
            //return a boolean
        }
    ],
]);

Patches & Features

  • Fork
  • Mod, fix
  • Test - this is important, so it's not unintentionally broken
  • Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of their own that I can ignore when I pull)
  • Pull request - bonus point for topic branches

To ensure your PRs are considered for upstream, you MUST follow the CakePHP coding standards.

Bugs & Feedback

http://github.com/usemuffin/orderly/issues

License

Copyright (c) 2015-Present, Use Muffin and licensed under The MIT License.

统计信息

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

GitHub 信息

  • Stars: 22
  • Watchers: 6
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-04