Set response static instances.

@return void
434633
protected function setResponseStaticInstances()
    {
        NodesHttpResponse::setFormatters(prepare_config_instances(config('nodes.api.response.formats')));
        NodesHttpResponse::setTransformer($this->app['api.transformer']);
        NodesHttpResponse::setEventDispatcher($this->app['events']);
    }
878231
public static function make(Request $request, Response $response)
    {
        if (is_null(static::$instance)) {
            static::$instance = new static($request, $response);
        }

        return static::$instance;
    }
319885
function initResponse(){
		if($this->action[0]=='_'){
			$this->response = new Response\JSONResponse();
		}else{
			$this->response = new Response\XTPLResponse($this);
			$this->response->setVariable('MODULE',$this);
			$this->response->post = $this->post;
			$this->response->get = $this->get;
			$this->response->website = Env::getConfig('website');
		}
	}
686047
public function prepareResponse()
    {
        try {
            $this->setBaseMiddlewares();
            $this->handleRequest($this->middlewares);
            $this->router->build();
            $this->handleRequest($this->routeMiddlewares);
            $this->response = $this->router->run();
        } catch (Exception $exception) {
            $response = $this->container->call([$this->getExceptionHandler(), 'render'], [$exception]);
            $this->response = $response ?: $this->response;
        }
    }
348734
public function setParameters()
	{		
		//set the url parameter from the UrlParserObjectInstance
		$this->parameters = $this->UrlParserObjectInstance->getParameters();

		//populate the Input Class data
		Input::setGet()->setPost();
		
		//return this object instance
		return $this;

	}
1133784
static function request()
    {
        self::$origin_get = $_GET;
        self::$origin_post = $_POST;
        self::$origin_request = $_REQUEST;
        self::$origin_cookie = $_COOKIE;

        $_POST = Filter::filterArray($_POST);
        $_GET = Filter::filterArray($_GET);
        $_REQUEST = Filter::filterArray($_REQUEST);
        $_COOKIE = Filter::filterArray($_COOKIE);
    }
92392
public static function setResponseStatus(int $status) : void
    {
        if (array_key_exists($status, Http::$http_status_messages)) {
            header('HTTP/1.1 ' . $status . ' ' . Http::$http_status_messages[$status]);
        }
    }
829589
public function initStatusFromResponse()
    {
        // Setting wrapper status
        if ($this->serverRawResponse->isSuccess()) {
            $this->status = true;
        } else {
            $this->status = false;
        }
    }
740830
protected function respond()
    {
        $response = [];

        if (!empty($this->meta)) {
            $response['meta'] = $this->meta;
        }

        $response['data'] = $this->data;

        if ($this->data instanceof Arrayable) {
            $response['data'] = $this->data->toArray();
        }

        return Response::json($response, $this->statusCode, $this->headers);
    }
805099
private function initResponse(): App
    {
        try {
            $response = new Response();
            $this->containers()->set('response', $response);
        } catch (\InvalidArgumentException $e) {
            new Exception($e);
        }
        return $this;
    }
838414
public static function putMapping()
    {
        $instance = new static;
        $mapping = $instance->basicElasticParams();
        $params = array(
            '_source'       => array('enabled' => true),
            'properties'    => $instance->getMappingProperties()
        );

        $mapping['body'][$instance->getTypeName()] = $params;

        return $instance->getElasticClient()->indices()->putMapping($mapping);
    }
308055
public function set()
    {
        // Register term meta on Rest API.
        if (function_exists('current_filter') && 'init' === current_filter()) {
            call_user_func($this->register());
        } else {
            $this->action->add('init', $this->register());
        }

        // Display fields.
        $this->action->add($this->taxonomy->getName().'_add_form_fields', $this->outputAddFields());
        $this->action->add($this->taxonomy->getName().'_edit_form_fields', $this->outputEditFields());

        // Save fields values.
        $this->action->add([
            'create_'.$this->taxonomy->getName(),
            'edit_'.$this->taxonomy->getName()
        ], $this->save());
    }
555244
static function init()
    {
        if (SettingsDatabase::NEED_CONNECT) {
            $connection_string = 'mysql:host=' . SettingsDatabase::HOST . ';port=' . SettingsDatabase::PORT . ';dbname=' . SettingsDatabase::DBNAME;

            ORM::configure('connection_string', $connection_string);
            ORM::configure('username', SettingsDatabase::USERNAME);
            ORM::configure('password', SettingsDatabase::PASSWORD);
            ORM::configure('logging', SettingsDatabase::LOGGING);
            ORM::configure('driver_options', [
                PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
                PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
            ]);
        }
    }
743877
protected function init()
    {
        if ($this->request->getResponseFormat() == 'xml') {
            $aggregated = new \SimpleXMLElement('<response/>');
            foreach ($this->responseRaw as $name => $response) {
                $child = $aggregated->addChild('classification');
                $child->addAttribute('classifier', $name);
                $xml = simplexml_load_string($response);

                if (! $xml instanceof \SimpleXMLElement) {
                    throw new ServiceReaderException('Failed parsing XML response.');
                }

                if ((string) $xml->status->attributes()->success !== 'true') {
                    throw new ServiceReaderException($xml->status->attributes()->statusCode);
                }

                foreach ($xml->readCalls->classify as $classify) {
                    $child->addAttribute('textCoverage', $classify->classification->attributes()->textCoverage);
                    foreach ($classify->classification->class as $class) {
                        $this->simplexmlImportXml($child, $class->asXML());
                    }
                }
            }

            return $aggregated->asXML();
        }

        if ($this->request->getResponseFormat() == 'json') {
            $aggregated = array();
            foreach ($this->responseRaw as $name => $response) {
                $current = json_decode($response, 1);

                if (! array_key_exists('success', $current)) {
                    throw new ServiceReaderException('Unable to complete request');
                }

                if ($current['success'] !== true) {
                    throw new ServiceReaderException($current['statusCode'] . ' ' . $current['errorMessage']);
                }

                array_key_exists('textCoverage', $current) ? '' : $current['textCoverage'] = null;
                array_key_exists('cls1', $current) ? '' : $current['cls1'] = null;

                $aggregated[] = array(
                    'classifier' => $name,
                    'textCoverage' => $current['textCoverage'],
                    'classes' => $current['cls1']
                );
            }

            return json_encode($aggregated);
        }

        return $this->responseRaw;
    }
958461
public function setRawResponse($response)
    {
        $parts = explode("\r\n\r\n", $response);

        if (count($parts) == 2) {
            $matches = array();
            $this->responseBody = $parts[1];

            if (preg_match_all(
                '/(HTTP\/[1-9]\.[0-9]\s+(?<statusCode>\d+)\s+(?<statusMessage>.*)'.
                        "|(?<headerName>[^:]+)\\s*:\\s*(?<headerValue>.*))\r\n/m",
                    $parts[0], $matches)) {
                foreach ($matches['statusCode'] as $offset => $match) {
                    if (!empty($match)) {
                        $this->statusCode = (int) $match;
                        $this->statusMessage = $matches['statusMessage'][$offset];
                        break;
                    }
                }

                foreach ($matches['headerName'] as $offset => $name) {
                    if (!empty($name)) {
                        $key = strtolower($name);
                        $header = array('name' => $name,
                            'value' => $matches['headerValue'][$offset],
                        );

                        if (isset($this->responseHeader[$key])) {
                            if (isset($this->responseHeader[$key]['name'])) {
                                $this->responseHeader[$key] = array(
                                    $this->responseHeader[$key],
                                );
                            }

                            $this->responseHeader[$key][] = $header;
                        } else {
                            $this->responseHeader[$key] = $header;
                        }
                    }
                }
            }
        } else {
            $this->responseBody = $response;
        }
    }
808301
protected static function initialize()
    {
        $class = static::class;

        if (static::$constants === null) {
            static::$constants = (new \ReflectionClass($class))->getConstants();

            foreach (static::names() as $name) {
                static::$lcKeyMap[strtolower($name)] = $name;
            }
        }
    }
766334
static public function instance()
    {
        $key = get_called_class();
        if (!isset(static::$instances[$key])) {
            $object = new static();
            $object->setCache(Ioc::cache('widget'));
            static::$instances[$key] = $object;
        }
        return static::$instances[$key];
    }