Create a new successful model state.

@param ModelInterface $model
@param string         $processName
@param string         $stepName
@param ModelState     $previous

@return \Lexik\Bundle\WorkflowBundle\Entity\ModelState
164187
public function newModelStateSuccess(ModelInterface $model, $processName, $stepName, $previous = null)
    {
        $modelState = $this->createModelState($model, $processName, $stepName, $previous);
        $modelState->setSuccessful(true);

        $this->om->persist($modelState);
        $this->om->flush($modelState);

        return $modelState;
    }
581428
public function findAllModelStates(ModelInterface $model, $processName, $successOnly = true)
    {
        return $this->repository->findModelStates(
            $model->getWorkflowIdentifier(),
            $processName,
            $successOnly
        );
    }
883018
public function beforeDelete(Model $model, $cascade = true) {
		$runtime = $this->runtime[$model->alias];
		if ($runtime) {
			if ($model->beforeDelete($cascade)) {
				return $this->delete($model, $model->id);
			}
			return false;
		}
		return true;
	}
1117312
public function findModelStates($workflowIdentifier, $processName, $successOnly)
    {
        $qb = $this->createQueryBuilder('ms')
            ->andWhere('ms.workflowIdentifier = :workflow_identifier')
            ->andWhere('ms.processName = :process')
            ->orderBy('ms.createdAt', 'ASC')
            ->setParameter('workflow_identifier', $workflowIdentifier)
            ->setParameter('process', $processName)
        ;

        if ($successOnly) {
            $qb->andWhere('ms.successful = :success')
                ->setParameter('success', true);
        }

        return $qb->getQuery()->getResult();
    }
503812
protected function insertModelAsFirstChildOf(Model &$model, Model &$parent)
    {
        if ($parent->isNew())
            throw new Exception('Parent model should be saved before child insert');

        /** @var \T4\Orm\Model $class */
        $class = get_class($model);
        $tableName = $class::getTableName();
        /** @var \T4\Dbal\Connection $connection */
        $connection = $class::getDbConnection();

        $parent->refreshTreeColumns();
        $width = $model->getTreeWidth();
        $this->expandTreeInElementFirst($parent, $width);
        if (!$model->isNew()) {
            $model->refreshTreeColumns();
        }

        $diff = $parent->__lft - $model->__lft + 1;
        $lvlDiff = $parent->__lvl - $model->__lvl + 1;

        if (!$model->isNew()) {

            $query = (new Query())
                ->update()
                ->table($tableName)
                ->values([
                    '__lft' => '__lft + :diff',
                    '__rgt' => '__rgt + :diff',
                    '__lvl' => '__lvl + :lvldiff',
                    '__prt' => 'CASE WHEN __id=:id THEN :parentid ELSE __prt END',
                ])
                ->where('__lft>=:lft AND __rgt<=:rgt')
                ->params([':lft'=>$model->__lft, ':rgt'=>$model->__rgt, ':diff'=>$diff, ':lvldiff'=>$lvlDiff, ':id'=>$model->getPk(), ':parentid'=>$parent->getPk()]);
            $connection->execute($query);

            $this->removeFromTreeByElement($model);

        }

        $model->__lft = $parent->__lft + 1;
        $model->__rgt = $parent->__lft + $width + 1;
        $model->__lvl = $parent->__lvl + 1;
        $model->__prt = $parent->getPk();
    }
96693
protected function addStepFileCheck(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model)
    {
        if ($this->onStartStep() && $this->isNextClicked()) {
            return;
        }
        $this->nextDisabled = true;

        $this->displayHeader($bridge, $this->_('Checking the content of the file.'), 'h3');

        $batch = $this->getImportCheckBatch();
        $form  = $bridge->getForm();

        $batch->setFormId($form->getId());
        $batch->autoStart = true;

        // \MUtil_Registry_Source::$verbose = true;
        if ($batch->run($this->request)) {
            exit;
        }

        $element = $form->createElement('html', $batch->getId());

        if ($batch->isFinished()) {
            $this->nextDisabled = $batch->getCounter('import_errors');
            $batch->autoStart   = false;

            // Keep the filename after $batch->getMessages(true) cleared the previous
            $this->addMessage($batch->getMessages(true));
            if ($this->nextDisabled) {
                $element->pInfo($this->_('Import errors occurred!'));
            } else {
                $element->h3($this->_('Import checks OK!'));
                $element->pInfo($this->_('Click the "Next" button to continue.'));
            }
        } else {
            $element->setValue($batch->getPanel($this->view, $batch->getProgressPercentage() . '%'));
        }

        $form->activateJQuery();
        $form->addElement($element);
    }
921069
public function createStartingWith($stageContextFqcn, PipelineModifications $pipelineModifications)
    {
        $stepChainBuilder = $this->chainBuilderFactory->createChainBuilder($stageContextFqcn, $pipelineModifications);

        $stepRegistrations = $stepChainBuilder->build();
        $stepInstances = [];
        foreach ($stepRegistrations as $registration) {
            $stepInstances[] = $this->builder->build($registration->getStepFqcn());
        }

        return new Pipeline($stepInstances);
    }
250643
private function createStateMachine($stateMachineName)
    {
        $stateMachine = new StateMachine($stateMachineName);
        $stateMachine->addState(new InitialState());
        $stateMachine->addState(new FinalState());
        $stateMachine->addState(new State(self::$STATE_START));
        $stateMachine->addTransition(
            $stateMachine->getState(StateInterface::STATE_INITIAL),
            new TransitionEvent(EventInterface::EVENT_START),
            $stateMachine->getState(self::$STATE_START),
            null,
            null
        );

        return $stateMachine;
    }
391268
function previousStep()
    {
        $this->setMetaData( 'current_stage', eZWizardBase::STAGE_PRE );
        $this->setMetaData( 'current_step', $this->metaData( 'current_step' ) - 1 );
        $this->savePersistentData();

        return $this->Module->redirectTo( $this->WizardURL );
    }
226863
protected function applyPostProcessorsToModel(Model $model)
    {
        foreach ($this->postProcessors as $processorClass => $parameters) {

            // if a processor class was added as a value instead of a key, it
            // does not have parameters
            if (is_numeric($processorClass)) {
                $processorClass = $parameters;
                $parameters     = null;
            }

            $processor = $this->makePostProcessor($processorClass, $parameters);

            $model = $processor->process($model);
        }

        return $model;
    }
53904
public function createEntry($model, $inputs)
    {
        $row = $model::create($inputs);

        if ($row) {
            notify()->success('Successfully',
                'A new ' . $this->formatModelName($model) . ' has been created');
        }
        else {
            notify()->error('Oops', 'Something went wrong');
        }

        return $row;
    }
1126005
protected function assertHasStepForEvent($eventName)
    {
        if (!isset($this->eventBindings[$eventName])) {
            throw new NoStepForEventFoundException(
                sprintf('No step handling event %s in scenario %s.', $eventName, get_class($this->scenario))
            );
        }
    }
375526
protected function callStepAndCheckForException($stepName, $args = array())
    {
        try {
            $response = call_user_func_array(array($this->exampleClass, $stepName), $args);
        } catch (OffAmazonPaymentsService_Exception $ex) {
            $this->printExceptionToCLI($ex, $stepName);
            throw $ex;
        }

        return $response;
    }
310133
public function process() {
        /* @var $currentStep StepController */
        /* @var $ancestorStep StepController */
        /* @var $descendantStep StepController */
        $currentStep = $this->stepCollectionIterator->current();
        if ($this->stepAction == self::WIZARD_STEP_ACTION_PREV && !$this->stepCollection->isFirst($this->stepCollectionIterator->current())) {
            $currentStep->leaveToAncestorStep();
            $this->stepCollectionIterator->previous();
            $ancestorStep = $this->stepCollectionIterator->current();
            $ancestorStep->enterFromDescendant();
            $this->resultContent = $this->prepareNextStepView($ancestorStep);
        } elseif ($this->stepAction == self::WIZARD_STEP_ACTION_PREV && $this->stepCollection->isFirst($this->stepCollectionIterator->current())) {
            $this->resultContent = new ResponseConfigurator();
        }
        if ($this->stepAction == self::WIZARD_STEP_ACTION_NEXT) {
            $currentStep->preProcess();
            if ($currentStep->process($currentStep->standardClosureArguments())) {
                $currentStep->postProcess();
                $currentStep->leaveStep();
                $this->stepCollectionIterator->next();

                $descendantStep = $this->stepCollectionIterator->current();
                $descendantStep->enterStep();
                $this->resultContent = $this->prepareNextStepView($descendantStep);
            } else {
                $this->resultContent = $this->prepareNextStepView($currentStep);
                $this->resultContent->setVariable("errorMessage", $currentStep->getProcessErrorMessage());
            }

        }
    }
898789
protected function getProcessStep($stepName)
    {
        $step = $this->process->getStep($stepName);

        if (! ($step instanceof Step)) {
            throw new WorkflowException(sprintf('Can\'t find step named "%s" in process "%s".', $stepName, $this->process->getName()));
        }

        return $step;
    }
452054
private function createIntrospectedTransition($methodName, StateInterface $fromState)
    {
        $toState = $this->getToState($fromState, $methodName);

        return new IntrospectedTransition(
            $methodName,
            $this->introspectedStates[$fromState->getKey()],
            $this->introspectedStates[$toState->getKey()]
        );
    }
1009602
protected function determineModelState(ModelInterface $model, $level)
    {
        $model->setMeta(DCGE::TREE_VIEW_LEVEL, $level);
        $model->setMeta(
            $model::SHOW_CHILDREN,
            $this->getTreeNodeStates()->isModelOpen(
                $model->getProviderName(),
                $model->getId()
            )
        );
    }