Return an instance of this class.
@codeCoverageIgnore
@since 1.0.0

@param array $request_data Current REQUEST superglobals

@return ui A single instance of this class
559434
public static function get_instance( $request_data ) {

		// If the single instance hasn't been set, set it now.
		if ( isset( self::$instance ) ) {
			self::$instance->data = $request_data;
		} else {
			self::$instance       = new self;
			self::$instance->data = $request_data;
			self::$instance->auto_load();
		}

		return self::$instance;

	}
508141
private function initParams($requestId)
    {
        $controller = $this->params[$requestId]['controller'];
        if (!is_array($controller) || empty($controller[0]) || !is_object($controller[0])) {
            throw new \InvalidArgumentException(
                'Controller needs to be set as a class instance (closures/functions are not supported)'
            );
        }

        $class = class_exists(ClassUtils::class)
            ? ClassUtils::getClass($controller[0])
            : get_class($controller[0]);

        return $this->params[$requestId]['params'] = $this->paramReader->read(
            new \ReflectionClass($class),
            $controller[1]
        );
    }
551486
public function getCustomers(Get\RequestData $requestData = null)
    {
        $request = new Get\Request($requestData);

        $apiResponse = $this->sendRequest($request, Get\ApiResponse::class);

        /** @var Get\Response $response */
        $response = $apiResponse->getResponse();
        foreach ($response->getCustomers() as $customer) {
            if ($customer->getBirthday() instanceof \DateTime) {
                $customer->getBirthday()->setTime(0, 0, 0);
            }
        }

        return $apiResponse;
    }
495966
public function create($data)
    {
        $response = $this->api->post($this->url(), $data);
        $className = $this->objectClass;

        return new $className($this->api, $this, $response->data);
    }
1031889
public function buildGetRequestObject(string $url, array $data = null): Request
    {
        $requestOptions = [
            RequestOptions::QUERY => $data
        ];
        $options = $this->buildRequest(self::METHOD_GET, $url, $requestOptions);
        $headers = isset($options[self::OPTION_OPTIONS][RequestOptions::HEADERS]) ? $options[self::OPTION_OPTIONS][RequestOptions::HEADERS] : [];
        $body = isset($options[self::OPTION_OPTIONS][RequestOptions::BODY]) ? $options[self::OPTION_OPTIONS][RequestOptions::BODY] : null;
        $version = isset($options[self::OPTION_OPTIONS][RequestOptions::VERSION]) ? $options[self::OPTION_OPTIONS][RequestOptions::VERSION] : '1.1';
        return new Request($options[self::OPTION_METHOD], $options[self::OPTION_URL], $headers, $body, $version);
    }
1167277
public function getUri($data = null)
    {
        if (null === $data) {
            $folder_id = $this->container->get('cms.context')->getCurrentFolderId();
        } elseif ($data instanceof Node) {
            $folder_id = $data->getFolderId();
        } elseif ($data instanceof Folder) {
            $folder_id = $data->getId();
        } elseif (intval($data)) {
            $folder_id = $data;
        } else {
            throw new \Exception('Unknown input type.');
        }

        $cache_key = md5('cms_folder.full_path.'.$folder_id);
        if (false == $uri = $this->cache->get($cache_key)) {
            $uri = '/';
            $uri_parts = [];

            /* @var $folder Folder */
            while ($folder_id != 1) {
                $folder = $this->repository->findOneBy([
                    'id'         => $folder_id,
                    'is_active'  => true,
//                    'is_deleted' => false,
                ]);

                if ($folder) {
                    $folder_id = $folder->getParentFolder()->getId();
                    $uri_parts[] = $folder->getUriPart();
                } else {
                    break;
                }
            }

            $uri_parts = array_reverse($uri_parts);
            foreach ($uri_parts as $value) {
                $uri .= $value.'/';
            }

            $this->cache->set($cache_key, $uri, ['folder']);
        }

        return $this->container->get('request_stack')->getMasterRequest()->getBaseUrl().$uri;
    }
536594
public static function createExisting($data)
    {
        $newRequest = new static($data);
        $newRequest->setId($data['id']);
        $newRequest->setExists(true);

        return $newRequest;
    }
1300997
public function get($resource = null, $data = array())
    {
        return $this->call($resource, AnHttpRequest::GET, $data);
    }
771543
public function newInstance($data=null)
    {
        $class = $this->getClassName();
        $conv = $this->newConverterInstance();

        if(is_null($data))
        {
            $data = array();
        }

        if($conv instanceof IListConverter)
        {
            $data = $conv;
        }

        $o = new $class($data);
        if($conv instanceof IBaseConverter)
        {
            $o->setConverter($conv);
        }

        return $o;
    }
1085812
public function setSubscriptionUsageData(SetUsageData\RequestData $requestData)
    {
        $request = new SetUsageData\Request($requestData);

        return $this->sendRequest($request, SetUsageData\ApiResponse::class);
    }
531303
public function load($data)
    {
        foreach ($data as $row) {
            $this->put($row['id'], RequestEntity::createExisting($row));
        }

        return $this;
    }
1120207
public function getRequest()
    {
        if(!$this->_request instanceof KControllerRequestInterface)
        {
            $this->_request = $this->getObject($this->_request,  array(
                'url'  => $this->getIdentifier(),
            ));

            if(!$this->_request instanceof KControllerRequestInterface)
            {
                throw new UnexpectedValueException(
                    'Request: '.get_class($this->_request).' does not implement KControllerRequestInterface'
                );
            }
        }

        return $this->_request;
    }
615332
public function getRequest(): RequestInterface
    {
        if (is_null($this->request)) {
            if (method_exists($this, 'resolve')) {
                $this->setRequest($this->resolve(Request::class)->load());
            } else {
                $request = new Request();
                $this->setRequest($request->load());
            }
        }

        return $this->request;
    }
566551
public static function getResponder(Request $request)
    {
        if ($request instanceof HttpRequest) {
            return self::getHttpResponder($request);
        } else {
            $requestType = get_class($request);
            throw new \InvalidArgumentException("Requests of type '{$requestType}' are not supported.");
        }
    }
1288750
public static function instance( $uri = false )
    {
        // If $uri is false we assume the caller wants eZSys::requestURI()
        if ( $uri === false or $uri == eZSys::requestURI() )
        {
            if ( !isset( $GLOBALS['eZURIRequestInstance'] ) )
            {
                $GLOBALS['eZURIRequestInstance'] = new eZURI( eZSys::requestURI() );
            }
            return $GLOBALS['eZURIRequestInstance'];
        }

        return new eZURI( $uri );
    }
148639
public function initByData( array $data = null )
    {

        if( !$data ) {
            return null;
        }

        // table inheritance - ghetto?
        /*
        if( isset( $data['tableoid'] ) ) {
            if( $data['tableoid'] != static::OID ) {
                $repo = Repository::init( $data['tableoid'] );
                return $repo->initByData( $data );
            }
            unset( $data['tableoid'] );
        }
        */

        $key = call_user_func(
            array( $this->entityClass, 'keyGet' ),
            $data
        );

        // is this already in the cache? Are we initalising something we've already loaded?
        if( isset( $this->instancesPersisted[$key] ) ) {

            // Late loading? Don't need this anymore.
            $obj = $this->instancesPersisted[$key];
            $obj->__construct( $data );
            return $obj;

        }

        $obj = parent::initByData($data);
        $this->instancesPersisted[$key] = $obj;

        return $obj;

    }
161773
public static function setMvc($request_uri = null) {
		// storing previous mvc settings
		if (\Application::get('mvc.module')) {
			$mvc_prev = \Application::get('mvc_prev');
			if (is_array($mvc_prev)) $mvc_prev = [];
			$mvc_prev[] = \Application::get('mvc');
			\Application::set('mvc_prev', $mvc_prev);
		}
		// processing
		$request_uri = !empty($request_uri) ? $request_uri : $_SERVER['REQUEST_URI'];
		// routing based on rules
		$request_uri = self::route($request_uri);
		// parsing request
		$data = self::mvc($request_uri);
		// forming class name and file
		if (in_array('Controller', $data['controllers'])) {
			$controller_class = str_replace(' ', '\\', implode(' ', $data['controllers']));
			$file = './../libraries/private/' . str_replace('\\', DIRECTORY_SEPARATOR, $controller_class . '.php');
			if (!file_exists($file)) {
				$file = './../libraries/vendor/' . str_replace('\\', DIRECTORY_SEPARATOR, $controller_class . '.php');
			}
		} else {
			$controller_class = 'Controller\\' . str_replace(' ', '\\', implode(' ', $data['controllers']));
			$file = './' . str_replace('\\', DIRECTORY_SEPARATOR, $controller_class . '.php');
		}
		$controller_class = '\\' . $controller_class;
		// assembling everything into settings
		$data = $data;
		$data['controller_class'] = $controller_class;
		$data['controller_action'] = 'action' . str_replace('_', ' ', $data['action']);
		$data['controller_action_code'] = $data['action'];
		$data['controller_id'] = $data['id'];
		$data['controller_view'] = $data['action'];
		$data['controller_layout'] = \Application::get('application.layout.layout') ?? 'index';
		$data['controller_layout_extension'] = \Application::get('application.layout.extension') ?? 'html';
		$data['controller_layout_file'] = \Application::get(['application', 'path_full']) . 'Layout/' . $data['controller_layout'] . '.' . $data['controller_layout_extension'];
		$data['controller_file'] = $file;
		\Application::set('mvc', $data);
	}