Load a template by path

@param   string  $url      The template url
@throws \InvalidArgumentException If the template could not be located
@return KTemplate
966132
public function loadFile($url)
    {
        //Locate the template
        $locator = $this->getObject('template.locator.factory')->createLocator($url);

        if (!$file = $locator->locate($url)) {
            throw new InvalidArgumentException(sprintf('The template "%s" cannot be located.', $url));
        }

        $type = pathinfo($file, PATHINFO_EXTENSION);

        if(!in_array($type, $this->_excluded_types))
        {
            //Create the template engine
            $config = array(
                'template' => $this,
                'functions' => $this->_functions
            );

            $this->_source = $this->getObject('template.engine.factory')
                ->createEngine($file, $config)
                ->loadFile($url);
        }
        else parent::loadFile($url);

        return $this;
    }
1157509
public function initFromUrl($url)
    {
        
        $options = [
            'http' => [
                'method'=>"GET",
                'header'=>"Accept-language: en\r\n".
                "User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2\r\n"
          ]
        ];
        
        $context  = stream_context_create($options);
        

        if ($data = @file_get_contents($url, false, $context)) {
            return $this->initFromBinary($data);
        }

        throw new \Intervention\Image\Exception\NotReadableException(
            "Unable to init from given url (".$url.")."
        );
    }
280919
protected function load($name)
    {
        if ($name instanceof \Twig_Template) {
            return $name;
        }

        try {
            return $this->environment->loadTemplate($name);
        } catch (\Twig_Error_Loader $e) {
            throw new \InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
        }
    }
522805
public function loadFromUrl(string $url, array $header = []): JWKSet
    {
        $content = $this->getContent($url, $header);
        $data = $this->jsonConverter->decode($content);
        if (!\is_array($data)) {
            throw new \RuntimeException('Invalid content.');
        }

        $keys = [];
        foreach ($data as $kid => $cert) {
            if (false === \mb_strpos($cert, '-----BEGIN CERTIFICATE-----')) {
                $cert = '-----BEGIN CERTIFICATE-----'.PHP_EOL.$cert.PHP_EOL.'-----END CERTIFICATE-----';
            }
            $jwk = KeyConverter::loadKeyFromCertificate($cert);
            if (\is_string($kid)) {
                $jwk['kid'] = $kid;
                $keys[$kid] = JWK::create($jwk);
            } else {
                $keys[] = JWK::create($jwk);
            }
        }

        return JWKSet::createFromKeys($keys);
    }
397872
public static function fromString($url)
    {
        static $defaults = ['scheme' => null, 'host' => null,
            'path' => null, 'port' => null, 'query' => null,
            'user' => null, 'pass' => null, 'fragment' => null];

        if (false === ($parts = parse_url($url))) {
            throw new \InvalidArgumentException('Unable to parse malformed '
                . 'url: ' . $url);
        }

        $parts += $defaults;

        // Convert the query string into a Query object
        if ($parts['query'] || 0 !== strlen($parts['query'])) {
            $parts['query'] = Query::fromString($parts['query']);
        }

        return new static($parts['scheme'], $parts['host'], $parts['user'],
            $parts['pass'], $parts['port'], $parts['path'], $parts['query'],
            $parts['fragment']);
    }
890547
public static function createFromUrl($url)
    {
        $instance = new static();

        if (self::$generic_file->fetchUrl($url, null, $instance)) {
            return $instance;
        }

        return;
    }
397520
public static function load($template)
	{
		// alter template so that it works
		$template = get_template_directory() != substr($template, 0, strlen(get_template_directory())) ? $template : substr($template, strlen(get_template_directory()) + 1);
		$template = get_stylesheet_directory() != substr($template, 0, strlen(get_stylesheet_directory())) ? $template : substr($template, strlen(get_stylesheet_directory()) + 1);
		$template = '.php' != substr($template, -4) ? $template : substr($template, 0, -4);
		// $template = 'templates.' == substr($template, 0, 10) ? $template : 'templates.' . $template;

		$mappedTemplate = static::mapTemplate($template);
		$template = locate_template($mappedTemplate);

		return new Loader($template);
	}
592867
public static function createFromUrl($url)
    {
        $url = (string) $url;
        $url = trim($url);
        $original_url = $url;
        $url = self::sanitizeUrl($url);

        //if no valid scheme is found we add one
        if (is_null($url)) {
            throw new RuntimeException(sprintf('The given URL: `%s` could not be parse', $original_url));
        }

        $components = array_merge(array(
            'scheme' => null,
            'user' => null,
            'pass' => null,
            'host' => null,
            'port' => null,
            'path' => null,
            'query' => null,
            'fragment' => null,
        ), self::parseUrl($url));
        $components = self::formatAuthComponent($components);
        $components = self::formatPathComponent($components, $original_url);

        return new static(
            new Components\Scheme($components['scheme']),
            new Components\User($components['user']),
            new Components\Pass($components['pass']),
            new Components\Host($components['host']),
            new Components\Port($components['port']),
            new Components\Path($components['path']),
            new Components\Query($components['query']),
            new Components\Fragment($components['fragment'])
        );
    }
854241
public function url($url)
    {
        if (filter_var($url, FILTER_VALIDATE_URL) !== false) {
            return $url;
        }

        if (is_string($url)) {
            return $this->parseStringUrl($url);
        }

        if (is_array($url)) {
            return $this->make(new UrlSettings($url));
        }

        if ($url instanceof UrlSettings) {
            return $this->make($url);
        }

        throw new \InvalidArgumentException('Settings is not a supported type');
    }
111142
public function load($path)
    {
        // Load template
        try {
            $template = $this->twig->loadTemplate($path);
        } catch (LoaderError $e) {
            throw new InvalidArgumentException("Error loading $path: ". $e->getMessage(), $e->getCode(), $e);
        }

        if ($template instanceof Template) {
            // Events are already fired by the View Environment
            $template->setFiredEvents(true);
        }

        return $template;
    }
647972
protected static function getTemplate($path)
    {
        if(file_exists($path))
            $template = file_get_contents($path);
        elseif(file_exists(__DIR__ . '/templates/' . $path))
            $template = file_get_contents(__DIR__ . '/templates/' . $path);
        else
            throw new \InvalidArgumentException('Template file not found.');

        return $template;
    }
387423
private function load($url) {
		if (!file_exists($url)) {
			throw new \n2n\log4php\LoggerException("File [$url] does not exist.");
		}
		
		$properties = \n2n\io\IoUtils::parseIniFile($url, true);
		if ($properties === false) {
			$error = error_get_last();
			throw new \n2n\log4php\LoggerException("Error parsing configuration file: {$error['message']}");
		}
		
		return $properties;
	}
1204188
public function setUrl($url)
    {
        if (!filter_var($url, FILTER_VALIDATE_URL))
        {
            throw new InvalidDataException('Invalid url link');
        }

        $this->url = $url;

        return $this;
    }
297413
public static function factory($url)
    {
        static $defaults = array('scheme' => null, 'host' => null, 'path' => null, 'port' => null, 'query' => null,
            'user' => null, 'pass' => null, 'fragment' => null);

        if (false === ($parts = parse_url($url))) {
            throw new InvalidArgumentException('Was unable to parse malformed url: ' . $url);
        }

        $parts += $defaults;

        // Convert the query string into a QueryString object
        if ($parts['query'] || 0 !== strlen($parts['query'])) {
            $parts['query'] = QueryString::fromString($parts['query']);
        }

        return new static($parts['scheme'], $parts['host'], $parts['user'],
            $parts['pass'], $parts['port'], $parts['path'], $parts['query'],
            $parts['fragment']);
    }
1153172
public function load($url)
    {
        if (file_exists($url)) {
            return $this->validate($url);
        }

        if (preg_match('#^(https?|spdy)://#', $url)) {

            if ($file = $this->loadRemoteFile($url)) {
                return $this->validate($file);
            }
        }

        throw new ImageResourceLoaderException(sprintf('Invalid Source URL: %s', $url));
    }
1106594
public static function parse(string $url): UrlInterface
    {
        if (!self::myParse(null, $url, $scheme, $host, $port, $path, $queryString, $fragment, $error)) {
            throw new UrlInvalidArgumentException($error);
        }

        return new self($scheme, $host, $port, $path, $queryString, $fragment);
    }
522291
private function loadTemplate($template)
    {
        if (!array_key_exists($template, $this->templateCache)) {
            $this->templateCache[$template] = $this->twig->loadTemplate($template);
        }

        return $this->templateCache[$template];
    }