Saves a time next to a token.
This can be use to measure import tasks.

@param string $token A free chosen token. e.g. starttime, endtime, ...
@param int $time A timestamp or another time identifier
@return void
967926
protected function setTime($token, $time = 0)
    {
        if ($time == 0) {
            $time = time();
        }

        $this->timer[$token] = $time;
    }
1281081
protected function endProfile($token)
    {
        if (isset($this->profileTokens[$token])) {
            $time = microtime(true) - $this->profileTokens[$token];

            unset($this->profileTokens[$token]);
        }
        else {
            $time = 0;
        }

        $this->log(" done (time: " . sprintf('%.3f', $time) . "s)\n");
    }
455742
static function init( $time=null )
    {
        if (self::$start == null || $time != null)
        {
            if ($time == null)
            {
                $time = microtime(true);
            }
            self::$start = $time;
        }
        if (self::$hostname == null)
        {
            self::$hostname = gethostname();
        }
        if (self::$script_name == null && isset($_SERVER['SCRIPT_NAME']))
        {
            self::$script_name = $_SERVER['SCRIPT_NAME'];
        }
        if (self::$server_name == null && isset($_SERVER['SERVER_NAME']))
        {
            self::$server_name = $_SERVER['SERVER_NAME'];
        }
        if ( !self::$shutdown_registered )
        {
            self::$shutdown_registered = true;
            register_shutdown_function('pinba::flush');
        }

    }
1008236
private function saveScrefToken($token)
    {
        /**
         * 保存到cookie
         */
        $this->vitex->res->setCookie("csrf_token",$token);
        /**
         * 保存到http header中
         */
        $this->vitex->res->setHeader("X-Csrf-Token",$token);
        /**
         * 设置到 response中传递给模板变量
         */
        $this->vitex->res->set("csrf_token",$token);
    }
552204
public function setToken(string $token)
    {
        if (empty($selector)) {
            Throw new TokenException('Empty tokens are not allowed.');
        }

        $this->token = $token;
    }
139846
private function deleteToken($token)
    {
        $obj = $this->modelFactory()->create(LostPasswordToken::class);
        $obj->setToken($token);
        $obj->delete();
    }
432950
public function move(Token $token) {
			$this->begin = $token->begin;
			$this->end = $token->end;

			unset($this->after, $this->before);
		}
825350
public function setExpireTime(int $time) : bool
        {
                return $this->_redis->expireat($this->_key, $time) > 0 ? true : false;
        }
721049
protected function _setStorageTimeUpload($time = null) {
		$time = (int)$time;
		if ($time > 0) {
			$this->_storageTimeUpload = $time;
		}
	}
1264964
protected function setTime($time) {

        if ($time === null) {
            $time = 0;
        }

        $this->time = new \DateTime('@' . $time);
        return $this;

    }
458188
public function setStartTime($startTime)
    {
        if ($startTime instanceof \DateTime)
        {
            $startTime = $startTime->format('H:i');
        }

        // deal with "hour-only" input
        if (2 == strlen($startTime))
        {
            $startTime .= ':00';
        }

        $this->start_time = $startTime;

        // Let's go ahead and set the default end_time
        $end_time = $this->getEndTimeFromStartTime($this->getStartTimeObject())
            ->format('H:i')
        ;
        $this->setEndTime($end_time);
    }
1308114
protected function clearToken($token)
    {
        $token = $this->tokenize($token);
        $this->checkToken($token);
        $this->tokens[$token] = array();
    }
1241700
protected function tokenExpired($token)
    {
        if (!$this->isExpirationEnabled()) {
            return false;
        }

        $expirationTime = strtotime($token['created_at']) + $this->expires;

        return $expirationTime < $this->getCurrentTime();
    }
858891
public function updateLastActivity(string $time = null): void
    {
        $this->timestamps = false;
        $this->last_activity = is_null($time) ? $this->freshTimestamp() : $time;
        $this->save();
    }
202164
protected function handleWhen(array $token)
    {

        $node = $this->createNode('when', $token);
        $node->subject = $token['subject'];
        $node->default = $token['default'];
        $this->current = $node;
    }
189158
public function tokenLoginAction($token)
    {
        $newSessionId = $this->loginTokenCache->get($token);
        $this->loginTokenCache->remove($token);

        if ($newSessionId === false) {
            $this->systemLogger->log(sprintf('Token-based login failed, non-existing or expired token %s', $token), LOG_WARNING);
            $this->redirect('index');
        }

        $this->systemLogger->log(sprintf('Token-based login succeeded, token %s', $token), LOG_DEBUG);

        $newSession = $this->sessionManager->getSession($newSessionId);
        if ($newSession->canBeResumed()) {
            $newSession->resume();
        }
        if ($newSession->isStarted()) {
            $newSession->putData('lastVisitedNode', null);
        } else {
            $this->systemLogger->log(sprintf('Failed resuming or starting session %s which was referred to in the login token %s.', $newSessionId, $token), LOG_ERR);
        }

        $this->replaceSessionCookie($newSessionId);
        $this->redirect('index', 'Backend\Backend');
    }
621382
protected function setRenderTime($time)
    {
        $merge = Yii::$app->session->get(self::ROBOTS_FILTER_SESSION_IDENTIFIER, []);
        Yii::$app->session->set(self::ROBOTS_FILTER_SESSION_IDENTIFIER, array_merge([$this->getSessionKeyByOwner() => $time], $merge));
    }