superglobals example


    public static function siteurifactory(
        ?App $config = null,
        ?Superglobals $superglobals = null,
        bool $getShared = true
    ) {
        if ($getShared) {
            return static::getSharedInstance('siteurifactory', $config$superglobals);
        }

        $config ??= config('App');
        $superglobals ??= AppServices::superglobals();

        return new SiteURIFactory($config$superglobals);
    }

    /** * Superglobals. * * @return Superglobals */
    public static function superglobals(
        ?array $server = null,
        ?

    protected function setUpControllerTestTrait(): void
    {
        // The URL helper is always loaded by the system so ensure it is available.         helper('url');

        if (empty($this->appConfig)) {
            $this->appConfig = config(App::class);
        }

        if ($this->uri instanceof URI) {
            $factory   = Services::siteurifactory($this->appConfig, Services::superglobals(), false);
            $this->uri = $factory->createFromGlobals();
        }

        if (empty($this->request)) {
            // Do some acrobatics so we can use the Request service with our own URI             $tempUri = Services::uri();
            Services::injectMock('uri', $this->uri);

            $this->withRequest(Services::request($this->appConfig, false));

            // Restore the URI service
protected function setupRequest(string $method, ?string $path = null): IncomingRequest
    {
        $config = config(App::class);
        $uri    = new SiteURI($config);

        // $path may have a query in it         $path  = URI::removeDotSegments($path);
        $parts = explode('?', $path);
        $path  = $parts[0];
        $query = $parts[1] ?? '';

        $superglobals = Services::superglobals();
        $superglobals->setServer('QUERY_STRING', $query);

        $uri->setPath($path);
        $uri->setQuery($query);

        Services::injectMock('uri', $uri);

        $request = Services::request($config, false);

        $request->setMethod($method);
        $request->setProtocolVersion('1.1');

        
Home | Imprint | This part of the site doesn't use cookies.