コード例 #1
0
ファイル: Pinba.php プロジェクト: bankiru/yii-pinba
 /**
  * Set custom script name instead of $_SERVER['SCRIPT_NAME'] used by default.
  * Useful for those using front controllers, when all requests are served by one PHP script.
  *
  * @param string $scriptName
  * @return Pinba
  */
 public function setScriptName($scriptName)
 {
     if ($this->enabled && $scriptName) {
         pinba_script_name_set($scriptName);
         $this->fixScriptName = false;
     }
     return $this;
 }
コード例 #2
0
 public function onRequest(GetResponseEvent $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     if (!function_exists('pinba_script_name_set') || PHP_SAPI === 'cli') {
         return;
     }
     pinba_script_name_set($event->getRequest()->getRequestUri());
 }
コード例 #3
0
ファイル: Middleware.php プロジェクト: sannis/laravel-pinba
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $return = $next($request);
     if (extension_loaded('pinba')) {
         $route = $request->route();
         if ($route) {
             $script_name = $route->getUri();
         } else {
             $script_name = self::UNKNOWN_SCRIPT_NAME;
         }
         pinba_script_name_set($script_name);
     }
     return $return;
 }
コード例 #4
0
ファイル: Action.php プロジェクト: voenniy/yii2-jsonrpc
 /**
  * @return mixed
  * @throws JsonRpcException
  */
 protected function getHandler()
 {
     if (strpos($this->getMethod(), '.') !== false) {
         list($object, $method) = explode(".", $this->getMethod());
         $pinba_filename = $object . "_" . $method;
         try {
             $object = Yii::createObject(JsonRPCModule::getInstance()->apiNamespace . '\\' . $object);
         } catch (\Exception $e) {
             throw new JsonRpcException($e->getMessage(), JsonRpcException::METHOD_NOT_FOUND, $e);
         }
     } else {
         $object = 'Base';
         $method = $this->getMethod();
         $class = get_class($this);
         $namespace = '';
         if (($pos = strrpos($class, '\\')) !== false) {
             $namespace = substr($class, 0, $pos) . '\\';
         }
         $pinba_filename = $object . "_" . $method;
         $object = Yii::createObject($namespace . $object);
     }
     if (function_exists('pinba_script_name_set')) {
         pinba_script_name_set($pinba_filename);
     }
     $this->setMethod($method);
     $this->setObject($object);
     $class = new \ReflectionClass($this->getObject());
     if (!$class->hasMethod($this->getMethod())) {
         throw new JsonRpcException("Method not found " . $this->getMethod(), JsonRpcException::METHOD_NOT_FOUND);
     }
     $method = $class->getMethod($this->getMethod());
     return $method;
 }
コード例 #5
0
ファイル: PinbaClient.php プロジェクト: justthefish/hesper
 public function setScriptName($name)
 {
     pinba_script_name_set($name);
     return $this;
 }
コード例 #6
0
 public static function setScriptName($scriptName)
 {
     if (self::init()) {
         return pinba_script_name_set($scriptName);
     }
 }
コード例 #7
0
ファイル: Pinba.php プロジェクト: sp-niemand/yii2-pinba
 /**
  * @inheritdoc
  */
 public function init()
 {
     $clientUsed = $this->getClientUsed();
     if (!$this->worksWithoutPinba && $clientUsed === self::CLIENT_NONE) {
         throw new InvalidConfigException('Pinba functionale not available');
     }
     parent::init();
     if ($this->remindAboutTimers) {
         \Yii::$app->attachBehavior('pinbaTimersRemind', ['class' => TimersRemindBehavior::className(), 'pinba' => $this]);
     }
     if ($clientUsed === self::CLIENT_PHP_EXTENSION) {
         ini_set('pinba.enabled', true);
         if ($this->server) {
             ini_set('pinba.server', $this->server);
         }
     }
     if ($clientUsed !== self::CLIENT_NONE) {
         $request = \Yii::$app->request;
         if ($request->isConsoleRequest) {
             pinba_script_name_set((isset($_SERVER['argv'][0]) ? $_SERVER['argv'][0] : '') . ' ' . (isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : ''));
         } else {
             pinba_script_name_set($request->getScriptUrl() . '/' . $request->getPathInfo());
         }
     }
 }