當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Profile::setIp方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpKernel\Profiler\Profile::setIp方法的典型用法代碼示例。如果您正苦於以下問題:PHP Profile::setIp方法的具體用法?PHP Profile::setIp怎麽用?PHP Profile::setIp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpKernel\Profiler\Profile的用法示例。


在下文中一共展示了Profile::setIp方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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']);
     return $profile;
 }
開發者ID:anthonysimone,項目名稱:d8_twig,代碼行數:13,代碼來源: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: testMultiRowIndexFile

 public function testMultiRowIndexFile()
 {
     $iteration = 3;
     for ($i = 0; $i < $iteration; $i++) {
         $profile = new Profile('token' . $i);
         $profile->setIp('127.0.0.' . $i);
         $profile->setUrl('http://foo.bar/' . $i);
         $storage = $this->getStorage();
         $storage->write($profile);
         $storage->write($profile);
         $storage->write($profile);
     }
     $handle = fopen(self::$tmpDir . '/index.csv', 'r');
     for ($i = 0; $i < $iteration; $i++) {
         $row = fgetcsv($handle);
         $this->assertEquals('token' . $i, $row[0]);
         $this->assertEquals('127.0.0.' . $i, $row[1]);
         $this->assertEquals('http://foo.bar/' . $i, $row[3]);
     }
     $this->assertFalse(fgetcsv($handle));
 }
開發者ID:ahmedibr,項目名稱:project,代碼行數:21,代碼來源:FileProfilerStorageTest.php

示例4: testDuplicates

 public function testDuplicates()
 {
     for ($i = 1; $i <= 5; $i++) {
         $profile = new Profile('foo' . $i);
         $profile->setIp('127.0.0.1');
         $profile->setUrl('http://example.net/');
         $profile->setMethod('GET');
         ///three duplicates
         $this->getStorage()->write($profile);
         $this->getStorage()->write($profile);
         $this->getStorage()->write($profile);
     }
     $this->assertCount(3, $this->getStorage()->find('127.0.0.1', 'http://example.net/', 3, 'GET'), '->find() method returns incorrect number of entries');
 }
開發者ID:ronaldlunaramos,項目名稱:webstore,代碼行數:14,代碼來源:AbstractProfilerStorageTest.php

示例5: createProfileFromData

 private 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']);
     if (!$parent && $data['parent']) {
         $parent = $this->read($data['parent']);
     }
     if ($parent) {
         $profile->setParent($parent);
     }
     foreach ($data['children'] as $token) {
         if (!$token) {
             continue;
         }
         if (!($childProfileData = $this->getValue($this->getItemName($token), self::REDIS_SERIALIZER_PHP))) {
             continue;
         }
         $profile->addChild($this->createProfileFromData($token, $childProfileData, $profile));
     }
     return $profile;
 }
開發者ID:rikaix,項目名稱:symfony,代碼行數:25,代碼來源:RedisProfilerStorage.php

示例6: 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;
 }
開發者ID:marchyoung,項目名稱:FrameworkBenchmarks,代碼行數:27,代碼來源:Profiler.php

示例7: testRetrieveByUrl

 public function testRetrieveByUrl()
 {
     $profile = new Profile('simple_quote');
     $profile->setIp('127.0.0.1');
     $profile->setUrl('http://foo.bar/\'');
     self::$storage->write($profile);
     $profile = new Profile('double_quote');
     $profile->setIp('127.0.0.1');
     $profile->setUrl('http://foo.bar/"');
     self::$storage->write($profile);
     $profile = new Profile('backslash');
     $profile->setIp('127.0.0.1');
     $profile->setUrl('http://foo\\bar/');
     self::$storage->write($profile);
     $profile = new Profile('percent');
     $profile->setIp('127.0.0.1');
     $profile->setUrl('http://foo.bar/%');
     self::$storage->write($profile);
     $profile = new Profile('underscore');
     $profile->setIp('127.0.0.1');
     $profile->setUrl('http://foo.bar/_');
     self::$storage->write($profile);
     $this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/\'', 10)), 1, '->find() accepts single quotes in URLs');
     $this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/"', 10)), 1, '->find() accepts double quotes in URLs');
     $this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo\\bar/', 10)), 1, '->find() accepts backslash in URLs');
     $this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/%', 10)), 1, '->find() does not interpret a "%" as a wildcard in the URL');
     $this->assertEquals(count(self::$storage->find('127.0.0.1', 'http://foo.bar/_', 10)), 1, '->find() does not interpret a "_" as a wildcard in the URL');
 }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:28,代碼來源:SqliteProfilerStorageTest.php

示例8: 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)));
     return $profile;
 }
開發者ID:ABaldwinHunter,項目名稱:durhamatletico-cms,代碼行數:16,代碼來源:DatabaseProfilerStorage.php

示例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;
 }
開發者ID:EnmanuelCode,項目名稱:backend-laravel,代碼行數:28,代碼來源:Profiler.php

示例10: createProfileFromData

 protected function createProfileFromData($token, $data, $parent = null)
 {
     $profile = new Profile($token);
     $profile->setIp($data['ip']);
     $profile->setUrl($data['url']);
     $profile->setTime($data['time']);
     $profile->setCollectors(unserialize(base64_decode($data['data'])));
     if (!$parent && isset($data['parent']) && $data['parent']) {
         $parent = $this->read($data['parent']);
     }
     if ($parent) {
         $profile->setParent($parent);
     }
     $profile->setChildren($this->readChildren($token, $profile));
     return $profile;
 }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:16,代碼來源:PdoProfilerStorage.php

示例11: testPurge

 public function testPurge()
 {
     $profile = new Profile('token1');
     $profile->setIp('127.0.0.1');
     $profile->setUrl('http://example.com/');
     $profile->setMethod('GET');
     $this->getStorage()->write($profile);
     $this->assertTrue(false !== $this->getStorage()->read('token1'));
     $this->assertCount(1, $this->getStorage()->find('127.0.0.1', '', 10, 'GET'));
     $profile = new Profile('token2');
     $profile->setIp('127.0.0.1');
     $profile->setUrl('http://example.net/');
     $profile->setMethod('GET');
     $this->getStorage()->write($profile);
     $this->assertTrue(false !== $this->getStorage()->read('token2'));
     $this->assertCount(2, $this->getStorage()->find('127.0.0.1', '', 10, 'GET'));
     $this->getStorage()->purge();
     $this->assertEmpty($this->getStorage()->read('token'), '->purge() removes all data stored by profiler');
     $this->assertCount(0, $this->getStorage()->find('127.0.0.1', '', 10, 'GET'), '->purge() removes all items from index');
 }
開發者ID:laubosslink,項目名稱:lab,代碼行數:20,代碼來源:AbstractProfilerStorageTest.php

示例12: 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;
 }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:27,代碼來源:Profiler.php


注:本文中的Symfony\Component\HttpKernel\Profiler\Profile::setIp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。