定制 slabphp/sequencer 二次开发

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

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

slabphp/sequencer

Composer 安装命令:

composer require slabphp/sequencer

包简介

SlabPHP Sequencer

README 文档

README

The Sequencer library is used to create re-usable class hierarchies of controllers. Methods are added to the sequencer so child controllers can add additional items to the sequence. The SlabPHP framework leverages these for most controllers.

SlabPHP was built many years ago, we're well aware about the distaste for protected members. For more information about SlabPHP, time travel, deprecation, life, love, and other things, please see the main SlabPHP framework documnetation.

Example

Lets pretend we have a parent class that looks like this:

<?php

class Parent
{
    /**
     * @var \Slab\Sequencer\CallQueue
     */
    protected $sequence;

    /**
     * @var int
     */
    protected $value = 0;

    /**
     * Public constructor
     */
    public function __construct()
    {
        $this->sequence = new \Slab\Sequencer\CallQueue();
        $this->value = 1;
    }

    /**
     * This adds the "doSomethingAlways" method to the Sequencer call queue but does not actually run it yet
     */
    public function setSequence()
    {
        $this->sequence
            ->doSomethingAlways();
    }

    /**
     * Multiply value by 2
     */
    public function doSomethingAlways()
    {
        $this->value *= 2;
    }

    /**
     * Actually run the functions in the sequence and echo the output
     */
    final public function execute()
    {
        $this->sequence->execute($this);

        echo $this->value;
    }
}

And you use this as your controller all over the place. But you want to make a similar controller with an additional action. You could extend it as follows:

<?php

class Child extends Parent
{
    /**
     * Overload and extend the setSequence function
     */
    public function setSequence()
    {
        parent::setSequence();

        $this->sequence
            ->doSomethingElse();
    }

    /**
     * Multiply the value again by 3
     */
    public function doSomethingElse()
    {
        $this->value *= 3;
    }
}

If you were to do the following:

$parent = new Parent();
$parent->execute(); //echos 2

But if you do:

$child =  new Child();
$child->execute(); //echos 6

统计信息

  • 总下载量: 88
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2018-03-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固