/**
* @param NULL|mixed $state scalar
*/
public function __construct($state = NULL)
{
$this->stateMachine = new StateMachine($this);
$this->getLoader()->load($this->stateMachine);
// intentionally set after ArrayLoader::load, as it sets symfony accessor
$this->stateMachine->setStateAccessor(new StatefulPropertyStateAccessor());
$this->stateMachine->initialize();
$this->setFiniteState($state ?: $this->getInitialState());
$this->onModify();
}