itinance / tiny-state-machine
1.0.3
2016-02-08 16:24 UTC
Requires
- php: >=5.3.2
- symfony/framework-bundle: ~2.7
- symfony/twig-bundle: ~2.7
Requires (Dev)
- phpunit/dbunit: 1.3.*
- phpunit/phpunit: 4.0.*
This package is not auto-updated.
Last update: 2024-12-21 20:14:04 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') %}