Switches the internal state to one of the supported states.

@param int $context State flag.
331209
public function setState($state)
    {
        $state &= ~248; // 0b11111000

        if (($state & ($state - 1)) !== 0) {
            throw new InvalidArgumentException("State must be a valid state value");
        }

        $this->setFlags($state);
        $this->streamCallback = null;
    }
934408
protected function _afterEntityDelete(AnCommandContext $context)
    {
        $this->subscribee->getRepository()
                         ->getBehavior('subscribable')
                         ->resetStats(array($this->subscribee));
    }
984321
protected function _actionDisable($context)
    {
        $context->response->status = AnHttpResponse::RESET_CONTENT;
        $this->getItem()->disable();

        return;
    }
675065
public function set_context($context) {
        if ($context === null) {
            // Extremely ugly hack which sets context to some value in order to prevent warnings,
            // use only for core error handling!!!!
            if (!$this->_context) {
                $this->_context = context_system::instance();
            }
            return;
        }
        // Ideally we should set context only once.
        if (isset($this->_context) && $context->id !== $this->_context->id) {
            $current = $this->_context->contextlevel;
            if ($current == CONTEXT_SYSTEM or $current == CONTEXT_COURSE) {
                // Hmm - not ideal, but it might produce too many warnings due to the design of require_login.
            } else if ($current == CONTEXT_MODULE and ($parentcontext = $context->get_parent_context()) and
                $this->_context->id == $parentcontext->id) {
                // Hmm - most probably somebody did require_login() and after that set the block context.
            } else {
                // We do not want devs to do weird switching of context levels on the fly because we might have used
                // the context already such as in text filter in page title.
                debugging("Coding problem: unsupported modification of PAGE->context from {$current} to {$context->contextlevel}");
            }
        }

        $this->_context = $context;
    }
704970
public function bind(Context $context)
    {
        if (! isset($context->__UBID)) {
            $context->__UBID = 0;
        }
        $context->__UBID ++;
        
        return spl_object_hash($context) . $context->__UBID;
    }
340592
public function run(MigrationContext $context)
	{
		$this->setContext($context);
		$this->createMigrationsTable();

		$all_migrations = $this->getAllMigrations();
		$executed_migrations = $this->getExecutedMigrations();

		$migrations_to_execute = array_diff($all_migrations, $executed_migrations);
		$this->executeMigrations($migrations_to_execute);

		$migrations_to_delete = array_diff($executed_migrations, $all_migrations);
		$this->deleteMigrations($migrations_to_delete);
	}
1188023
public function setContext($context)
    {
        if (!is_array($context) && !$context instanceof \ArrayObject && !$context instanceof \Iterator) {
            throw new EventException('Unexpected value type for context', EventException::INVALID_CONTEXT);
        }

        $context = Collection::cast($context);

        $this->context = $context;

        return $this;
    }
413294
public function run($context)
    {
        foreach ($this->actions as $step) {
            /** @var $step Action  **/
            codecept_debug("- $step");
            try {
                call_user_func_array([$context, $step->getAction()], $step->getArguments());
            } catch (\Exception $e) {
                $class = get_class($e); // rethrow exception for a specific action
                throw new $class($e->getMessage() . "\nat $step");
            }
        }
    }
418694
protected function _afterEntityDelete(AnCommandContext $context)
    {
        $this->getSpace()->setEntityState($context->entity, AnDomain::STATE_DESTROYED);
    }
283942
protected function _setState($state)
    {
        if ($state !== null && !is_string($state) && !($state instanceof Stringable)) {
            throw $this->_createInvalidArgumentException(
                $this->__('Argument is not a valid state'),
                null,
                null,
                $state
            );
        }

        $this->state = $state;
    }
930033
protected function _unlockResource(KControllerContextInterface $context)
    {
        if($this->isLockable() && $this->canEdit()) {
            $context->result->unlock();
        }
    }
93798
public function setReferenceContext(ReferenceContext $context)
    {
        foreach ($this->_paths as $key => $path) {
            if ($path === null) {
                continue;
            }
            $path->setReferenceContext($context);
        }
    }
341971
protected function _actionSetprivacy($context)
    {
        $data = $context->data;

        $names = AnConfig::unbox($data->privacy_name);

        settype($names, 'array');

        foreach ($names as $name) {
            $this->getItem()->setPermission($name, $data->$name);
        }
    }
370877
protected function _unlockReferrer(KControllerContextInterface $context)
    {
        $context->response->headers->clearCookie($this->_cookie_name.'_locked', $this->_cookie_path);
    }
496443
public function setActiveContext($context)
    {
        $oldLocale = isset($this->activeContext) ? $this->contextLocales[$this->activeContext] : null;
        $this->activeContext = $context;
        if (!isset($this->contextLocales[$context])) {
            $this->setContextLocale($context, static::BASE_LOCALE);
        }
        $newLocale = $this->contextLocales[$context];
        if ($newLocale !== $oldLocale) {
            $this->currentLocaleChanged($newLocale);
        }
    }
1171164
private function initializeInstance(Context $context)
    {
        foreach ($this->contextInitializers as $initializer) {
            $initializer->initializeContext($context);
        }
    }
842593
public function switchPinState($post)
    {
        $post->setPinned(!$post->isPinned());
        $this->om->persist($post);
        $this->om->flush();
    }