定制 soap/laravel-workflow-loader 二次开发

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

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

soap/laravel-workflow-loader

最新稳定版本:v0.2.1

Composer 安装命令:

composer require soap/laravel-workflow-loader

包简介

This is my package laravel-workflow-loader

README 文档

README

Latest Version on Packagist GitHub Tests Action Status PHPStan GitHub Code Style Action Status Total Downloads

This package extends zerodahero/laravel-workflow by adding option to store workflow configuration in database. Laravel workflow only support loading configuration form Laravel configuration. This package provides user to change workflow configuration without helping from developers.

Support us

You can suggest for any approvement, sponsor this project or make a pull request. I am happy to consider any recommendation. I am not a good programmer so my design may not be the best one. My background is not computer programming. I am an Electrical engineer.

Installation

You can install the package via composer:

composer require soap/laravel-workflow-loader

You can publish and run the migrations with:

php artisan vendor:publish --tag="workflow-loader-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="workflow-loader-config"

This is the contents of the published config file:

return [
    'loaders' => [
        'database' => [
            'tableNames' => [
                'workflows' => 'workflows',
                'workflow_states' => 'workflow_states',
                'workflow_transitions' => 'workflow_transitions',
                'workflow_state_transitions' => 'workflow_state_transitions',
            ],
            'class' => \Soap\WorkflowLoader\DatabaseLoader::class,
        ],
    ],
];

To use this package to load workflow configuration from database, you need to register workflow service provider provided by the package. Zerodahero 's workflow registry will be used to load configuration retreiving from database.

php artisan venodr:publish --tag="workflow-loader-provider"

This will copy the following WorkflowServiceProvider.php to application providers folder, ensure that it was included in application bootstrap. The following is the content of the file.

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class WorkflowServiceProvider extends ServiceProvider
{
    public function register() {}

    public function boot()
    {
        $registry = app()->make('workflow');
        $workflowLoaderRegistry = app()->make('workflowLoaderRegistry');   
        foreach ($workflowLoaderRegistry->all() as $workflow => $config) {
            $registry->addFromArray($workflow, $config);
        }
    }
}

This package doesnot provide user interface for user to manage workflow configuration. By design it should be in separate package. I have a plan to create filament plugin to handle this.

Usage

After you have completed setup, create workflow configuration in database using your own way or provided by other package. Then use them like the one you use by zerohadero/laravel-workflow. Storing configuration in database is easy to develop workflow for user.

Enhance your workflow

Using zerodahero/laravel-workflow, guards should be created via event subscriber. I developed soap/laravel-workflow-process to use Symfony expression as an upper guard layer. For example, you can write:

guard => $subject.isWaitingFor($user) || !$subject.isOwnedBy($user)

or

guard => $subject.isApprovers($user) || $subject.isReviewers($user)

Then the package will inject $subject and $user for you and use Symfony expression to evaluate blocking of the transition.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-19