承接 naghashyan/ngs-state-manager 相关项目开发

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

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

naghashyan/ngs-state-manager

Composer 安装命令:

composer require naghashyan/ngs-state-manager

包简介

Manage DTOs state change functional

README 文档

README

Naghashyan State Management Library

This library used for help state management, it will control if object state can be changed from X -> Y. To create state manager instance you should use NgsStateManagerFactory. It has 2 static methods:

1. createJsonStateManager

This function should get 2 parameters: $statesConfigs, $ngsStateableMapper $statesConfigs is array which will help to library to understand which next states has current state, and who can change state $statesConfigs structure should be like this:

[
  "states" => [
    [
      "name" => "state1",   // the name of state, for changing state you should pass name of state as an expecting state change
      "description" => "desc1", // the description of state
      "nextStates" => [   //nextStates - is array which informs about possible states which can be changed from state 'state1'
        [
          "name" => "state2", // possible change state name
          "userGroups" => ["userGroup1", "userGroup2"] // user goups list who can change to this state
        ],
        [
          "name" => "state3",
          "userGroups" => ["userGroup1"]
        ]
      ],
      "beforeActions": ["URL1", "URL2"],  //list of urls which will be called before state change functional
      "afterActions": ["URL3"] //list of urls which will be called after state change functional
    ],
    [
      "name" => "state2",
      "description" => "desc2",
      "nextStates" => [
        {
          "name" => "state3",
          "userGroups" => ["userGroup2"]
        }
      ],
      "beforeActions" => [],
      "afterActions" => ["URL3"]
    ],
    [
      "name" => "state3",
      "description" => "desc3",
      "nextStates" => [],
      "beforeActions" => ["URL4"],
      "afterActions" => []
    ]
  ]
]

$ngsStateableMapper is mapper of object, to work with this library, mapper should implement INgsStateableMapper interface

createJsonStateManager function after call will return instance of NgsJsonStateManager which has method changeState($stateableDto, string $newStateName, string $userGroup)
$stateableDto is dto object which should implement INgsStateableDto interface

changeState method will return boolean if state changed or not or can throw exception NgsStateException

2. createDbStateManager

This function should get $ngsStateableMapper as parameter $ngsStateableMapper is mapper of object, to work with this library, mapper should implement INgsStateableMapper interface

createDbStateManager function after call will return instance of NgsDBStateManager this manager to understand state change ruls uses table ngs_states the row of table should has this columns:

name - name of state description - description of state next_states - json which has same structure as 'nextStates' described above before_actions - json array of urls which will be called before state change functional after_actions - json array of urls which will be called after state change functional

NgsDBStateManager has method changeState($stateableDto, string $newStateName, string $userGroup) $stateableDto is dto object which should implement INgsStateableDto interface

changeState method will return boolean if state changed or not or can throw exception NgsStateException

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固