Source of file WorkflowFieldTransitionController.php
Size: 2,126 Bytes - Last Modified: 2021-12-23T10:27:27+00:00
/var/www/docs.ssmods.com/process/src/src/FormFields/WorkflowFieldTransitionController.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 | <?php namespace Symbiote\AdvancedWorkflow\FormFields; use SilverStripe\Control\Controller; use SilverStripe\Control\RequestHandler; use Symbiote\AdvancedWorkflow\DataObjects\WorkflowAction; use Symbiote\AdvancedWorkflow\DataObjects\WorkflowTransition; /** * Handles requests for creating or editing transitions. * * @package silverstripe-advancedworkflow */ class WorkflowFieldTransitionController extends RequestHandler { private static $url_handlers = array( 'new/$ParentID!' => 'handleAdd', 'item/$ID!' => 'handleItem' ); private static $allowed_actions = array( 'handleAdd', 'handleItem' ); protected $parent; protected $name; public function __construct($parent, $name) { $this->parent = $parent; $this->name = $name; parent::__construct(); } public function handleAdd() { $parent = $this->request->param('ParentID'); $action = WorkflowAction::get()->byID($this->request->param('ParentID')); if (!$action || $action->WorkflowDefID != $this->RootField()->Definition()->ID) { $this->httpError(404); } if (!singleton(WorkflowTransition::class)->canCreate()) { $this->httpError(403); } $transition = new WorkflowTransition(); $transition->ActionID = $action->ID; return new WorkflowFieldItemController($this, "new/$parent", $transition); } public function handleItem() { $id = $this->request->param('ID'); $trans = WorkflowTransition::get()->byID($id); if (!$trans || $trans->Action()->WorkflowDefID != $this->RootField()->Definition()->ID) { $this->httpError(404); } if (!$trans->canEdit()) { $this->httpError(403); } return new WorkflowFieldItemController($this, "item/$id", $trans); } public function RootField() { return $this->parent; } public function Link($action = null) { return Controller::join_links($this->parent->Link(), $this->name, $action); } } |