Saves application state in persistent storage.
@param mixed $state state data (must be serializable).
@return int
185843
public function save($state)
	{
		$command=$this->db->createCommand();
		if(false===$this->exists())
			return $command->insert($this->stateTableName,array(
				$this->keyField=>Yii::app()->name,
				$this->valueField=>serialize($state)
			));
		else
			return $command->update($this->stateTableName,array($this->valueField=>serialize($state)),
				$this->db->quoteColumnName($this->keyField).'=:key',
				array(':key'=>Yii::app()->name)
		);
	}
1280515
public function storeCSRFState(string $service, string $state):OAuthStorageInterface{
		$this->states[$service] = $state;

		return $this;
	}
1141183
private function writeSetState( $file )
    {
        fwrite( $file, "    /**\n" );
        fwrite( $file, "     * Set the PersistentObject state.\n" );
        fwrite( $file, "     *\n" );
        fwrite( $file, "     * @param array(string=>mixed) \$state The state to set.\n" );
        fwrite( $file, "     * @return void\n" );
        fwrite( $file, "     */\n" );
        fwrite( $file, "     public function setState( array \$state )\n" );
        fwrite( $file, "     {\n" );
        fwrite( $file, "         foreach ( \$state as \$attribute => \$value )\n" );
        fwrite( $file, "         {\n" );
        fwrite( $file, "             \$this->\$attribute = \$value;\n" );
        fwrite( $file, "         }\n" );
        fwrite( $file, "     }\n" );
    }
290998
public function saveDocument($postValues, $state = 'unpublished')
    {
        if (!in_array($state, Document::$DOCUMENT_STATES, true)) {
            throw new \RuntimeException('Unsupported document state: ' . $state);
        }
        $oldPath = '/' . $postValues['path'];

        $container = $this->getDocumentContainerByPath($oldPath);
        $documentObject = DocumentFactory::createDocumentFromPostValues($postValues,
            new DocumentTypesStorage($this->repository));
        if ($container->path === '/') {
            $newPath = $container->path . $documentObject->slug;
        } else {
            $newPath = $container->path . '/' . $documentObject->slug;
        }
        $documentObject->path = $newPath;
        $this->repository->getContentRepository()->saveDocument($documentObject, $state);
        return $newPath;
    }
752960
public function setRecordState($state)
    {
        if ($state != null) {
            $this->flush();
            $this->record = StringHelper::booleanValue($state);
        }
    }
251343
public static function setValidationState( $state = true)
	{
		$previousState = XBRL::$validating;
		XBRL::$validating = $state;
		return $previousState;
	}
881588
public function process( BootstrapState $state ) {
		$commands        = $this->get_protected_commands();
		$current_command = $this->get_current_command();

		foreach ( $commands as $command ) {
			if ( 0 === strpos( $current_command, $command ) ) {
				$state->setValue( BootstrapState::IS_PROTECTED_COMMAND, true );
			}
		}

		return $state;
	}
891421
protected function setState(int $state) : bool
    {
        $this->workerState = $state;

        // report idle state to server:
        $this->replySocket->send(json_encode([
            'request' => 'change_state',
            'worker_id' => $this->workerId,
            'state' => $this->workerState
        ]));
        $response = $this->replySocket->recv();
        return ($response === 'ok');
    }
1108856
public function save($entity)
    {

        $objectManager = $this->getObjectManager();

        //@TODO UnitOfWork::STATE_NEW == $em->getUnitOfWork()->getEntityState($entity)
        //@see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-objects.html#entity-state
        $objectManager->persist($entity);
        $objectManager->flush();
    }
883105
public function canJumpToState($state)
    {
        if ($state instanceof StateInterface) {
            $state = $state->getName();
        }

        // assert that the given state exists
        $this->getState($state);

        return in_array($this->currentState->getName(), $this->statePrecedence[$state], true);
    }
1275306
public function setState($state) {
        $statusProp = $this->getProperty(OntologyDeliveryExecution::PROPERTY_STATUS);
        $state = $this->getResource($state);
        $currentStatus = $this->getState();
        if ($currentStatus->getUri() == $state->getUri()) {
            common_Logger::w('Delivery execution '.$this->getIdentifier().' already in state '.$state->getUri());
            return false;
        }
        $this->editPropertyValues($statusProp, $state);
        if ($state->getUri() == DeliveryExecutionInterface::STATE_FINISHED) {
            $this->setPropertyValue($this->getProperty(OntologyDeliveryExecution::PROPERTY_TIME_END), microtime());
        }
        $this->state = $state;
        return true;
    }
1259704
public function changeState($state)
    {
        $availableStates = $this->dbObject('Status')->enumValues();
        if (in_array($state, $availableStates)) {
            $this->Status = $state;
            return true;
        } else {
            user_error(_t('Reservation.STATE_CHANGE_ERROR', 'Selected state is not available'));
            return false;
        }
    }
371703
private function saveJobState(JobConfigurationInterface $configuration, $state)
    {
        $configuration->setState($state);
        $this->configurationManager->add($configuration, true);
        
        $this->eventDispatcher->dispatch(JobQueueEvents::CHANGE_JOB_STATE, new JobEvent($configuration));
    }
1246201
public function getState() : ?int 
    {
        if ( ! $this->hasState()) {
            $this->setState($this->getDefaultState());
        }
        return $this->state;
    }
1043810
public function get($state) : State
    {
        $this->addCallback('GET', $state);
        if (!isset($this->actions['POST'])) {
            $this->addCallback('POST', $state);
        }
        return $this;
    }
945424
def _save_state(self, state_file, last_pk):
        """"""
        fp = open(state_file, 'w+')
        try:
            fp.write(str(last_pk))
        finally:
            fp.close()
139246
public function saveState()
	{
        if($this->sessionEnabled()) {
            // Session handling.
            if(!is_array($this->sessionvars)) {
                $this->sessionvars = array();
            }
            foreach($this->sessionvars as $varname => $val) {
                if($val === null) {
                    unset($_SESSION[$varname]);
                }
                else {
                    $_SESSION[$varname] = $val;
                }
            }
        }

        if(!headers_sent()) {
            foreach($this->cookievars as $cookiename => $cookiedef) {
                if($cookiedef['value'] === null) {
                    setcookie($cookiename, null, time() - 3600, '/'); // Expiring the cookie
                }
                else {
                    setcookie(
                        $cookiename,
                        $cookiedef['value'],
                        time() + $cookiedef['max_age'],
                        '/'
                    );
                }
            }
        }
	}