PHP Класс izzum\statemachine\builder\ModelBuilder

This will thus not build the model when the statemachine asks for it, but rather the model is built when your application code creates it. This class is useful if your domain model actually subclasses the StateMachine class or uses object composition to use the statemachines' logic internally. In that case, you can construct the StateMachine in your models' constructor, including the Context with this class in it and with the domain model itself ($this) as an argument to the builder, so you can put our event handlers on the domain model and have them respond to the statemachine. eg: in the constructor of your domain model that uses object composition $builder = new ModelBuilder($this); $identifier = new Identifier($this->getId(), 'my-model-machine'); $context = new Context($identifier, $builder); $this->machine = new StateMachine($context); eg: in the constructor of your domain model that uses StateMachine as its' superclass $builder = new ModelBuilder($this); $identifier = new Identifier($this->getId(), 'my-model-machine'); $context = new Context($identifier, $builder); parent::__construct($context)
Автор: Rolf Vreijdenberger
Наследование: extends izzum\statemachine\EntityBuilder
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( mixed $model )

Защищенные методы

Метод Описание
build ( Identifier $identifier ) {@inheritDoc}

Описание методов

__construct() публичный метод

public __construct ( mixed $model )
$model mixed the domain model you want to have returned from this class.

build() защищенный метод

{@inheritDoc}
protected build ( Identifier $identifier )
$identifier izzum\statemachine\Identifier