当前位置: 首页>>代码示例>>PHP>>正文


PHP Profile::setStatusCode方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpKernel\Profiler\Profile::setStatusCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::setStatusCode方法的具体用法?PHP Profile::setStatusCode怎么用?PHP Profile::setStatusCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpKernel\Profiler\Profile的用法示例。


在下文中一共展示了Profile::setStatusCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createProfileFromData

 /**
  * {@inheritdoc}
  */
 protected function createProfileFromData($token, $data, $parent = NULL)
 {
     $profile = new Profile($token);
     $profile->setIp($data['ip']);
     $profile->setMethod($data['method']);
     $profile->setUrl($data['url']);
     $profile->setTime($data['time']);
     $profile->setCollectors($data['data']);
     $profile->setStatusCode($data['status_code']);
     return $profile;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:14,代码来源:FileProfilerStorage.php

示例2: testOk

 /**
  * @param boolean $secure
  * @dataProvider getSecureInsecure
  */
 public function testOk($secure)
 {
     $listener = new DebugResponseListener(['enabled' => true, 'key_name' => '_debug']);
     $listener->setProfilerListener($this->profileListener);
     $listener->addConverter(new FooConverter());
     $response = new Response(json_encode(['some' => ['data']]), 200, ['Content-Type' => 'application/json', 'X-Debug-Token-Link' => '/token']);
     $request = new Request([], [], [], [], [], ['SERVER_NAME' => 'foobar.test', 'SERVER_PORT' => $secure ? 443 : 80, 'HTTPS' => $secure ? 'on' : 'off']);
     $profile = new Profile('token');
     $profile->addCollector(new TimeDataCollector());
     $profile->setIp('8.8.8.8');
     $profile->setMethod(Request::METHOD_HEAD);
     $profile->setUrl('/some/url');
     $profile->setStatusCode(Response::HTTP_I_AM_A_TEAPOT);
     $profile->setTime(1000000);
     $this->profiles[$request] = $profile;
     $listener->onKernelResponse($this->getEvent($request, $response));
     $debugResponse = json_decode($response->getContent(), true);
     $this->assertEquals(['some' => ['data'], '_debug' => ['tokenUrl' => $secure ? 'https://foobar.test/token' : 'http://foobar.test/token', 'ip' => '8.8.8.8', 'method' => Request::METHOD_HEAD, 'url' => '/some/url', 'time' => date('c', 1000000), 'statusCode' => Response::HTTP_I_AM_A_TEAPOT, 'foo' => 'bar']], $debugResponse);
 }
开发者ID:ibrows,项目名称:rest-bundle,代码行数:23,代码来源:DebugResponseListenerTest.php

示例3: testStatusCode

 public function testStatusCode()
 {
     $profile = new Profile('token1');
     $profile->setStatusCode(200);
     $this->storage->write($profile);
     $profile = new Profile('token2');
     $profile->setStatusCode(404);
     $this->storage->write($profile);
     $tokens = $this->storage->find('', '', 10, '');
     $this->assertCount(2, $tokens);
     $this->assertContains($tokens[0]['status_code'], array(200, 404));
     $this->assertContains($tokens[1]['status_code'], array(200, 404));
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:13,代码来源:FileProfilerStorageTest.php

示例4: 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;
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:28,代码来源:Profiler.php

示例5: createProfileFromData

 /**
  * @param string $token
  * @param $data
  *
  * @return Profile
  */
 private function createProfileFromData($token, $data)
 {
     $profile = new Profile($token);
     $profile->setIp($data->ip);
     $profile->setMethod($data->method);
     $profile->setUrl($data->url);
     $profile->setTime($data->time);
     $profile->setCollectors(unserialize(base64_decode($data->data)));
     $profile->setStatusCode($data->status_code);
     return $profile;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:17,代码来源:DatabaseProfilerStorage.php


注:本文中的Symfony\Component\HttpKernel\Profiler\Profile::setStatusCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。