本文整理汇总了PHP中Symfony\Component\HttpKernel\Profiler\Profile::getToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::getToken方法的具体用法?PHP Profile::getToken怎么用?PHP Profile::getToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\Profiler\Profile
的用法示例。
在下文中一共展示了Profile::getToken方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* @param Profile $profile
*/
public function save(Profile $profile)
{
$dto = new ProfileDto();
$dto->token = $profile->getToken();
$dto->serialized = base64_encode(serialize($profile));
$this->entityManager->persist($dto);
$this->entityManager->flush();
}
示例2: write
/**
* {@inheritdoc}
*/
public function write(Profile $profile)
{
$args = ['token' => $profile->getToken(), 'parent' => $profile->getParentToken(), 'data' => base64_encode(serialize($profile->getCollectors())), 'ip' => $profile->getIp(), 'method' => $profile->getMethod(), 'url' => $profile->getUrl(), 'time' => $profile->getTime(), 'created_at' => time()];
try {
$query = $this->database->select('webprofiler', 'w')->fields('w', ['token']);
$query->condition('token', $profile->getToken());
$count = $query->countQuery()->execute()->fetchAssoc();
if ($count['expression']) {
$this->database->update('webprofiler')->fields($args)->condition('token', $profile->getToken())->execute();
} else {
$this->database->insert('webprofiler')->fields($args)->execute();
}
$status = TRUE;
} catch (\Exception $e) {
$status = FALSE;
}
return $status;
}
示例3: getQuery
/**
* @param $profile ->getToken()
* @param int $qid
*
* @return array
*/
private function getQuery(Profile $profile, $qid)
{
$this->profiler->disable();
$token = $profile->getToken();
if (!($profile = $this->profiler->loadProfile($token))) {
throw new NotFoundHttpException($this->t('Token @token does not exist.', ['@token' => $token]));
}
/** @var DatabaseDataCollector $databaseCollector */
$databaseCollector = $profile->getCollector('database');
$queries = $databaseCollector->getQueries();
$query = $queries[$qid];
return $query;
}
示例4: write
/**
* {@inheritdoc}
*/
public function write(Profile $profile)
{
$db = $this->initDb();
$args = array(':token' => $profile->getToken(), ':parent' => $profile->getParent() ? $profile->getParent()->getToken() : '', ':data' => base64_encode(serialize($profile->getCollectors())), ':ip' => $profile->getIp(), ':url' => $profile->getUrl(), ':time' => $profile->getTime(), ':created_at' => time());
try {
$this->exec($db, 'INSERT INTO sf_profiler_data (token, parent, data, ip, url, time, created_at) VALUES (:token, :parent, :data, :ip, :url, :time, :created_at)', $args);
$this->cleanup();
$status = true;
} catch (\Exception $e) {
$status = false;
}
$this->close($db);
return $status;
}
示例5: saveStopwatchInfoInProfile
/**
* Update the profiles with the timing info and saves them.
*
* @param Profile $profile The root profile
* @param Boolean $updateChildren Whether to update the children altogether
*/
private function saveStopwatchInfoInProfile(Profile $profile, $updateChildren)
{
$profile->getCollector('time')->setEvents($this->stopwatch->getSectionEvents($profile->getToken()));
$this->profiler->saveProfile($profile);
if ($updateChildren) {
foreach ($profile->getChildren() as $child) {
$this->saveStopwatchInfoInProfile($child, true);
}
}
}
示例6: saveInfoInProfile
/**
* Update the profiles with the timing and events information and saves them.
*
* @param Profile $profile The root profile
* @param Boolean $updateChildren Whether to update the children altogether
*/
private function saveInfoInProfile(Profile $profile, $updateChildren)
{
try {
$collector = $profile->getCollector('memory');
$collector->updateMemoryUsage();
} catch (\InvalidArgumentException $e) {
}
try {
$collector = $profile->getCollector('time');
$collector->setEvents($this->stopwatch->getSectionEvents($profile->getToken()));
} catch (\InvalidArgumentException $e) {
}
try {
$collector = $profile->getCollector('events');
$collector->setCalledListeners($this->getCalledListeners());
$collector->setNotCalledListeners($this->getNotCalledListeners());
} catch (\InvalidArgumentException $e) {
}
$this->profiler->saveProfile($profile);
if ($updateChildren) {
foreach ($profile->getChildren() as $child) {
$this->saveInfoInProfile($child, true);
}
}
}
示例7: write
/**
* {@inheritdoc}
*/
public function write(Profile $profile)
{
$data = array('token' => $profile->getToken(), 'parent' => $profile->getParentToken(), 'children' => array_map(function ($p) {
return $p->getToken();
}, $profile->getChildren()), 'data' => $profile->getCollectors(), 'ip' => $profile->getIp(), 'method' => $profile->getMethod(), 'url' => $profile->getUrl(), 'time' => $profile->getTime());
if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime, self::REDIS_SERIALIZER_PHP)) {
// Add to index
$indexName = $this->getIndexName();
$indexRow = implode("\t", array($profile->getToken(), $profile->getIp(), $profile->getMethod(), $profile->getUrl(), $profile->getTime(), $profile->getParentToken())) . "\n";
return $this->appendValue($indexName, $indexRow, $this->lifetime);
}
return false;
}
示例8: collect
/**
* Collects data for the given Response.
*
* @param Request $request A Request instance
* @param Response $response A Response instance
* @param \Exception $exception An exception instance if the request threw one
*
* @return Profile|null A Profile instance or null if the profiler is disabled
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
if (false === $this->enabled) {
return;
}
$profile = new Profile(substr(sha1(uniqid(mt_rand(), true)), 0, 6));
$profile->setTime(time());
$profile->setUrl($request->getUri());
$profile->setIp($request->getClientIp());
$profile->setMethod($request->getMethod());
$response->headers->set('X-Debug-Token', $profile->getToken());
foreach ($this->collectors as $collector) {
$collector->collect($request, $response, $exception);
// forces collectors to become "read/only" (they loose their object dependencies)
$profile->addCollector(unserialize(serialize($collector)));
}
return $profile;
}
示例9: collect
/**
* Collects data for the given Response.
*
* @param Request $request A Request instance
* @param Response $response A Response instance
* @param \Exception $exception An exception instance if the request threw one
*
* @return Profile|null A Profile instance or null if the profiler is disabled
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
if (false === $this->enabled) {
return;
}
$profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
$profile->setTime(time());
$profile->setUrl($request->getUri());
$profile->setIp($request->getClientIp());
$profile->setMethod($request->getMethod());
$profile->setStatusCode($response->getStatusCode());
$response->headers->set('X-Debug-Token', $profile->getToken());
foreach ($this->collectors as $collector) {
$collector->collect($request, $response, $exception);
// we need to clone for sub-requests
$profile->addCollector(clone $collector);
}
return $profile;
}
示例10: getParentToken
/**
* Returns the parent token.
*
* @return null|string The parent token
*/
public function getParentToken()
{
return $this->parent ? $this->parent->getToken() : null;
}
示例11: collect
/**
* Collects data for the given Response.
*
* @param Request $request A Request instance
* @param Response $response A Response instance
* @param \Exception $exception An exception instance if the request threw one
*
* @return Profile|false A Profile instance or false if the profiler is disabled
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
if (false === $this->enabled) {
return;
}
$profile = new Profile(uniqid());
$profile->setTime(time());
$profile->setUrl($request->getUri());
$profile->setIp($request->server->get('REMOTE_ADDR'));
$response->headers->set('X-Debug-Token', $profile->getToken());
$collectors = array();
foreach ($this->collectors as $name => $collector) {
$collector->collect($request, $response, $exception);
// forces collectors to become "read/only" (they loose their object dependencies)
$profile->addCollector(unserialize(serialize($collector)));
}
return $profile;
}