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


PHP Injector::getInstance方法代碼示例

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


在下文中一共展示了Injector::getInstance方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: make_request

 public function make_request($options)
 {
     $injector = Injector::getInstance();
     $url = $options['url'];
     $method = $options['method'];
     $headers = $options['headers'];
     $body = isset($options['body']) ? $options['body'] : '';
     $response = null;
     if (isset($options['qs'])) {
         $qs = http_build_query($options['qs']);
         $url .= '?' . $qs;
     }
     $url = str_replace('%2C', ',', $url);
     if (isset($headers['Content-Type']) && $headers['Content-Type'] == 'application/json' && is_array($body)) {
         $body = json_encode($body);
     }
     Request::verifyPeer($injector->ssl_verification);
     $response = Request::send($options['method'], $url, $body, $headers);
     return $response;
 }
開發者ID:ratwix,項目名稱:PhototwixQT,代碼行數:20,代碼來源:HttpWrapper.php

示例2: make_request

    public function make_request($options) {
        $injector = Injector::getInstance();
        
        $url = $options['url'];
        $method = $options['method'];
        $headers = $options['headers'];
        $body = isset($options['body']) ? $options['body'] : '';
        $response = null;
        if (isset($options['qs'])) {
            $qs = http_build_query($options['qs']);
            $url.= '?' . $qs;
        }
        $url = str_replace('%2C', ',', $url);

        \Unirest::verifyPeer($injector->ssl_verification);
        if ($options['method'] == 'GET') {
            $response = \Unirest::get($url, $headers);
        }
        
        if ($options['method'] == 'POST') {
            $response = \Unirest::post($url, $headers, $body);
        }
        
        if ($options['method'] == 'PUT') {
            $response = \Unirest::put($url, $headers, $body);
        }
        
        if ($options['method'] == 'DELETE') {
            $response = \Unirest::delete($url, $headers);
        }
        
        if ($options['method'] == 'PATCH') {
            $response = \Unirest::patch($url, $headers, $body);
        }

        return $response;
    }
開發者ID:pombredanne,項目名稱:ArcherSys,代碼行數:37,代碼來源:HttpWrapper.php

示例3: processController

 private function processController()
 {
     $input = InputData::getInstance();
     $input->setGet($this->_params);
     $input->setPost($this->_router->GetPost());
     $file = ucfirst($this->_namespace) . '\\' . ucfirst($this->_controller);
     $this->_controller = $file;
     $realPath = str_replace('\\', DIRECTORY_SEPARATOR, '../' . $file . '.php');
     $realPath = realpath($realPath);
     if (file_exists($realPath) && is_readable($realPath)) {
         $calledController = new $file();
         if (method_exists($calledController, $this->_method)) {
             if ($this->isValidRequestMethod($calledController, $this->_method)) {
                 // Create binding model
                 $refMethod = new \ReflectionMethod($calledController, $this->_method);
                 $doc = $refMethod->getDocComment();
                 // Validate accessibility
                 $this->ValidateAuthorization($doc);
                 if (preg_match('/@param\\s+\\\\?([\\s\\S]+BindingModel)\\s+\\$/', $doc, $match)) {
                     $bindingModelName = $match[1];
                     $bindingModelsNamespace = App::getInstance()->getConfig()->app['namespaces']['Models'] . 'BindingModels/';
                     $bindingModelsNamespace = str_replace('../', '', $bindingModelsNamespace);
                     $bindingModelPath = str_replace('/', '\\', $bindingModelsNamespace . $bindingModelName);
                     $bindingReflection = new \ReflectionClass($bindingModelPath);
                     $properties = $bindingReflection->getProperties();
                     $params = array();
                     foreach ($properties as $property) {
                         $name = $property->getName();
                         $value = $input->postForDb($name);
                         if ($value === null) {
                             throw new \Exception("Invalid binding model! Property '{$name}' not found", 400);
                         } else {
                             $params[$name] = $value;
                         }
                     }
                     $bindingModel = new $bindingModelPath($params);
                     Injector::getInstance()->loadDependencies($calledController);
                     $calledController->{strtolower($this->_method)}($bindingModel);
                 } else {
                     Injector::getInstance()->loadDependencies($calledController);
                     $calledController->{strtolower($this->_method)}();
                 }
                 exit;
             } else {
                 throw new \Exception("Method does not allow '" . ucfirst($this->_requestMethod) . "' requests!", 500);
             }
         } else {
             throw new \Exception("'" . $this->_method . "' not found in '" . $file . '.php', 404);
         }
     } else {
         throw new \Exception("File '" . $file . '.php' . "' not found!", 404);
     }
 }
開發者ID:KonstantinKirchev,項目名稱:WebDevelopment,代碼行數:53,代碼來源:FrontController.php

示例4: __construct

 public function __construct($credentials = array())
 {
     $this->injector = Injector::getInstance();
     $this->credentials = $credentials;
 }
開發者ID:ratwix,項目名稱:PhototwixQT,代碼行數:5,代碼來源:RequestObject.php

示例5: __construct

 /**
  *
  *
  */
 public function __construct()
 {
     $this->injector = Injector::getInstance();
 }
開發者ID:ratwix,項目名稱:PhototwixQT,代碼行數:8,代碼來源:OAuth.php


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