Authenticates a user if is needed.

A user is needed to be authenticated if in the url a role and a firewall
is specified. Otherwise, the system will understand that is a public url

@param Url $url Url

@return $this Self object
501381
protected function authenticate(Url $url)
    {
        if (
            !$url->getOption('role') ||
            !$url->getOption('firewall')
        ) {
            return $this;
        }

        $session = $this->session;
        $firewall = $url->getOption('firewall');
        $role = $url->getOption('role');
        $user = $this
            ->environmentBuilder
            ->getAuthenticationUser($url->getOption('role'));

        $token = new UsernamePasswordToken($user, null, $firewall, [$role]);
        $session->set('_security_' . $firewall, serialize($token));
        $session->save();

        $cookie = new Cookie(
            $session->getName(),
            $session->getId()
        );
        $this
            ->client
            ->getCookieJar()
            ->set($cookie);

        return $this;
    }
30434
public function request($url)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
        curl_setopt($ch, CURLOPT_REFERER, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

        $result = curl_exec($ch);
        curl_close($ch);

        return json_decode($result);
    }
686771
public function to($url)
    {
        $params = ['url' => (string) $url];
        $this->executor->execute(DriverCommand::GET, $params);

        return $this;
    }
132685
public function setErrorURL($url = "")
    {
        if (!isset($this->data))
            $this->data = new stdClass();

        $this->data->ic_urlerror = $url;
        return $this;
    }
275431
public function validateUrl($url)
    {
        if ('' === $url) {
            return $this;
        }

        if (!is_string($url) || strlen($url) > 2000) {
            throw new InvalidArgumentException(
                'URL must be a string of at most 2,000 characters',
                400
            );
        }

        return $this;
    }
409284
public function externalUrl($url)
    {
        $this->link_type = self::LINK_EXTERNAL_URL;
        $this->link_value = [$url];
        $this->setOpenNewWindowOption();
        $this->setActive(false);

        return $this;
    }
475186
public function setUrl($url)
    {
        $url = parse_url($url);

        $this->setHost($url['host']);

        if(isset($url['port']))
        {
            $this->setPort($url['port']);
        }

        return $this;
    }
819282
public function url($url)
    {
        if ($this->isNotSetOrEmpty($url)) {
            throw CouldNotCreateButton::urlNotProvided();
        } elseif (! filter_var($url, FILTER_VALIDATE_URL)) {
            throw CouldNotCreateButton::invalidUrlProvided($url);
        }

        $this->payload['url'] = $url;
        $this->isTypeWebUrl();

        return $this;
    }
1298867
public function url($url = null)
    {
        if (!is_null($url) && true !== $url) {
            $this->url = $url;
            return $this;
        } elseif (!$this->url) {
            if ($this->isCli()) {
                $this->url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
            } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
                $this->url = $_SERVER['HTTP_X_REWRITE_URL'];
            } elseif (isset($_SERVER['REQUEST_URI'])) {
                $this->url = $_SERVER['REQUEST_URI'];
            } elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
                $this->url = $_SERVER['ORIG_PATH_INFO'] . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '');
            } else {
                $this->url = '';
            }
        }
        return true === $url ? $this->domain() . $this->url : $this->url;
    }
1159325
public function url( string$url ):self
	{
		$url= parse_url($url);

		if( !is_array($url) )
			throw new \Exception("Url '$url' is invalid.");

		foreach( $url as $key=>$value )
		{
			$this->$key= $value;
		}

		return $this;
	}
1037351
public function setUrl($url)
    {
        if (! empty($url)) {
            $segments = parse_url($url);

            foreach ($segments as $key => $value) {
                $this->$key = $value;
            }

            if ($this->format = pathinfo($this->path, PATHINFO_EXTENSION)) {
                $this->path = str_replace('.'.$this->format, '', $this->path);
            }
        }

        return $this;
    }
1339880
public function setUrl($url) {
        if (!is_string($url)) throw new IllegalTypeException('Illegal type of parameter $url: '.gettype($url));

        // TODO: validate URL

        if (strpos($url, ' ') !== false)
            throw new InvalidArgumentException('Invalid argument $url: '.$url);

        $this->url = $url;
        return $this;
    }
745118
public function redirect($url)
    {
        return new RedirectResponse(
            sprintf(self::PRE_AUTH_LINK, $this->getSuiteId(), $this->getCode(), urlencode($url))
        );
    }
599022
public function action(String $url = NULL)
    {
        $this->settings['attr']['action'] = IS::url($url) ? $url : Request::getSiteURL($url);

        return $this;
    }
219243
public function url(string $url) : self
    {
        $this->route = $url;

        $this->active($url);

        return $this;
    }
247665
public function performRequest($url)
    {
        $client = $this->getClient();

        return $this->response = $client->get($url);
    }
1265572
public static function fromUrl($url)
    {
        $client = new GuzzleHttp\Client();
        $response = $client->get($url);
        $jsonData = json_decode($response->getBody(), true);
        $instance = new self($jsonData);
        return $instance;
    }