@param string $name
@param mixed[]|null $state

@return StateInterface
504801
public function createState(string $name, array $state = null): StateInterface
    {
        $state = Maybe::unit($state);
        $state_implementor = $this->resolveStateImplementor($state);
        $settings = $state->settings->get() ?? [];
        $settings['_output'] = $state->output->get() ?? [];
        $state_instance = new $state_implementor(
            $name,
            new Settings($settings),
            $this->createValidator($name, $state),
            $this->expression_engine
        );
        if ($state->final->get() && !$state_instance->isFinal()) {
            throw new ConfigError("Trying to provide custom state that isn't final but marked as final in config.");
        }
        if ($state->initial->get() && !$state_instance->isInitial()) {
            throw new ConfigError("Trying to provide custom state that isn't initial but marked as initial in config.");
        }
        if ($state->interactive->get() && !$state_instance->isInteractive()) {
            throw new ConfigError(
                "Trying to provide custom state that isn't interactive but marked as interactive in config."
            );
        }
        return $state_instance;
    }
855390
public function setState(array $state): ORM
    {
        if (isset($state[$this->getPrimaryKey()])) {
            $this->state = $state;
        }

        $this->attributes = $state;

        return $this;
    }
77787
public function setPresetList($listName, $state=null)
    {
        $lists = $this->provider->getLists();

        if (is_array($listName)) {
            foreach ($listName as $list) {
                $this->setPresetList($list, $state);
            }
        } else {
            parent::setList($lists[$listName], $listName, $state);
        }

        return $this;
    }
981847
public function debug( $state = null )
    {
        $default = self::DEBUG_SIMULATE + self::DEBUG_SHOW_QUERY;
        if( is_bool( $state ) ) {
            $state = $state ? $default : 0;;
        } elseif ( $state === null ) {
            $state = $default;
        }
        $this->debug = $state;
        return $this->debug;
    }
353886
public function getState($name,$defaultValue=null)
	{
		return isset($this->_state[$name])?$this->_state[$name]:$defaultValue;
	}
184469
public function changeState($name)
    {
        $this->state = $name;
        $this->history[] = $name;
        $this->hasChanged = true;
    }
1235321
public function add(StateInterface $state): self
    {
        $cloned_set = clone $this;
        $cloned_set->internal_set->add($state);

        return $cloned_set;
    }
760357
public function getPersistentState($name) {
	
		$name = static::getCookiePrefix() . ucfirst($name);
		
		if (array_key_exists($name, $this->persistentState)) {
			return $this->persistentState[$name];
		} else if (isset($_COOKIE[$name])) {
			return json_decode($_COOKIE[$name]);
		} else {
			return NULL;
		}
		
	}
904593
function renderingTitle($state = null) {
		if (!is_null($state)) {
			$this->_renderingTitle = $state;
		}
		return $this->_renderingTitle;
	}
1265153
public function setState($state)
    {
        $this->complement['state'] = $state;
        $this->states['state'] = $state;
        $this->setStates();

        return $state;
    }
108390
public function createStatemachine($subject)
    {
        $process = $this->processDetector->detectProcess($subject);
        if ($this->stateNameDetector) {
            $stateName = $this->stateNameDetector->detectCurrentStateName($subject);
        } else {
            $stateName = null;
        }
        if ($this->mutexFactory) {
            $mutex = $this->mutexFactory->createMutex($subject);
        } else {
            $mutex = null;
        }

        $statemachine = new Statemachine($subject, $process, $stateName, $this->transitonSelector, $mutex);

        foreach ($this->statemachineObserver as $observer) {
            $statemachine->attach($observer);
        }

        return $statemachine;
    }
1064588
public function saveState(string $name, $value = null)
    {
        if (is_null($value)) {
            $value = $this;
        }

        $this->addResolver($name, function () use ($value) {
            return $value;
        });

        return $this;
    }
422840
public function setState(int $state): ControllerInterface
    {
        switch ($state) {
            case self::STATE_PLAYING:
                return $this->play();
            case self::STATE_PAUSED:
                return $this->pause();
            case self::STATE_STOPPED:
                return $this->pause();
        }
        throw new \InvalidArgumentException("Unknown state: {$state})");
    }
1143389
public function renderState($state)
    {
        $list = SiteState::getList();

        if (isset($list[$state])) {
            return $this->t($list[$state]);
        }

        return $this->t("Unknown");
    }
140720
public static function activate_state($state)
    {
        foreach (self::variants() as $variant => $instance) {
            if (isset($state[$variant]) && $instance->appliesToEnvironment()) {
                $instance->activateState($state[$variant]);
            }
        }
    }
290670
public function execute(State $state) {
        $errors = [];
        foreach ($state->functions as $function) {
            $errors = array_merge($errors, $this->verifyReturn($function, $state));
        }
        foreach ($state->methods as $method) {
            $errors = array_merge($errors, $this->verifyReturn($method, $state));
        }
        return $errors;
    }
672107
private function determineStartState(InputInterface $input, string $state_name = null): StateInterface
    {
        if (!$state_name) {
            return $this->getInitialState();
        }
        if (!$this->states->has($state_name)) {
            throw new ExecutionError("Trying to start statemachine execution at unknown state: ".$state_name);
        }
        $start_state = $this->states->get($state_name);
        if ($start_state->isFinal()) {
            throw new ExecutionError("Trying to (re)execute statemachine at final state: ".$state_name);
        }
        if ($start_state->isInteractive() && !$input->hasEvent()) {
            throw new ExecutionError("Trying to resume statemachine executing without providing an event/signal.");
        }
        return $start_state->isInteractive()
            ? $this->activateTransition($input, Output::fromInput($start_state->getName(), $input))
            : $start_state;
    }