Pimcore\WorkflowManagement\Workflow\Manager::validateAction PHP Метод

validateAction() публичный Метод

Validates that a transition between requested states can be done on an element NOTE: DOES NOT VALIDATE FIELDS @see performAction
public validateAction ( $actionName, $newState, $newStatus ) : boolean
$actionName
$newState
$newStatus
Результат boolean
    public function validateAction($actionName, $newState, $newStatus)
    {
        $element = $this->element;
        if (!$this->workflow->isGlobalAction($actionName)) {
            $availableActions = $this->getAvailableActions();
            //check the action is available
            if (!array_key_exists($actionName, $availableActions)) {
                $this->error = "Workflow::validateTransition, Action [{$actionName}] not available for element [{$element->getId()}] with status [{$this->getElementStatus()}]";
                Logger::debug($this->error);
                return false;
            }
            $actionToTake = $availableActions[$actionName];
            if ($this->actionHasTransition($actionToTake)) {
                //check that the new state is correct for the action taken
                if (!array_key_exists($newState, $actionToTake['transitionTo'])) {
                    $this->error = "Workflow::validateTransition, State [{$newState}] not a valid transition state for action [{$actionName}] from status [{$this->getElementStatus()}]";
                    Logger::debug($this->error);
                    return false;
                }
                $availableNewStatuses = $actionToTake['transitionTo'][$newState];
                //check that the new status is valid for the action taken
                if (!in_array($newStatus, $availableNewStatuses)) {
                    $this->error = "Workflow::validateTransition, Status [{$newState}] not a valid transition status for action [{$actionName}] from status [{$this->getElementStatus()}]";
                    Logger::debug($this->error);
                    return false;
                }
            }
        }
        return true;
    }