itinance/tiny-state-machine

1.0.3 2016-02-08 16:24 UTC

This package is not auto-updated.

Last update: 2024-10-26 19:05:25 UTC


README

Installation

composer require itinance/tiny-state-machine

Usage

This StateMachine enables to set some state in an application and to request this state elsewhere, even in Twig.

Setting state:

StateMachine::instance()->setState('Foobar');

Setting state with value:

StateMachine::instance()->setState('Foobar', 'barfoo');

Request state:

StateMachine::instance()->getState('Foobar' /* , $default */);

StateMachine::instance()->hasState('Foobar');
StateMachine::instance()->hasStateWithValue('Foobar', 'barfoo');

Twig:

{% if hasState('Foobar') %}