This method is used to set the template from a relative
path.

@param string $sRelativePathToFile  the relative path to the template
@throws Exception                   if the file is not found
@return void
510208
public function setTemplateFile(string $sRelativePathToFile) : void
  {
    if(!is_file($sRelativePathToFile)) {
      throw new \Exception('Template file not found.');
    }
    
    $sFileContent = file_get_contents($sRelativePathToFile);
    $this->setTemplate($sFileContent);
  }
964229
private function open($pathToFile)
    {
        $this->pathToFile = $pathToFile;
        if (!file_exists($this->pathToFile)) {
            throw new ImageException("File " . ($this->pathToFile) . " not found.", ImageException::AccessException);
        }
        $tmpImageSize = getimagesize($this->pathToFile);
        $this->width = (int)$tmpImageSize[0];
        $this->height = (int)$tmpImageSize[1];
        $this->type = (int)$tmpImageSize[2];
        switch ($this->type) {
            case self::GIF:
                $this->resource = imagecreatefromgif($this->pathToFile);
                break;
            case self::JPG:
                $this->resource = imagecreatefromjpeg($this->pathToFile);
                break;
            case self::PNG:
                $this->resource = imagecreatefrompng($this->pathToFile);
                break;
            case self::BMP:
                $this->resource = imagecreatefromwbmp($this->pathToFile);
                break;
            default:
                throw new ImageException("Unknown type of file " . ($this->pathToFile) . ".", ImageException::UnsupportedFormatException);
                break;
        }
    }
1300164
public function parseFromFile($pathToFile)
    {
        if (!file_exists($pathToFile)) {
            throw new Exception(
                "There is no {$pathToFile} file for parsing"
            );
        }

        try {
            $return = Yaml::parseFile($pathToFile);
        } catch (\Exception $e) {
            throw new Exception($e->getMessage(), $e->getCode(), $e);
        }

        return $return;
    }
388659
public function addTemplatePath($path)
    {
        if (is_array($this->templatesPath)) {
            if (array_search($path, $this->templatesPath)) {
                throw new \LogicException(sprintf('Templates path "%s" exists.', $path));
            } else {
                $this->templatesPath[] = $path;
            }
        } else if (is_string($this->templatesPath)) {
            $lastTemplate = $this->templatesPath;
            $this->templatesPath = array(
                $lastTemplate, $path
            );
        }
    }
167771
public static function setCachePath($pathCacheFile)
    {
        self::$cacheEnable = false;

        if (!empty($pathCacheFile) && file_exists($pathCacheFile)) {
            self::$cacheEnable = true;
            self::$cachePath   = $pathCacheFile;
        }
        elseif (!empty($pathCacheFile) && !file_exists(dirname($pathCacheFile))) {
            self::$cacheEnable = false;
            self::$cachePath   = $pathCacheFile;
        }
        elseif (!empty($pathCacheFile) && touch($pathCacheFile)) {
            unlink($pathCacheFile);
            self::$cacheEnable = true;
            self::$cachePath   = $pathCacheFile;
        }
    }
84816
public function generate(
        $vendor,
        $namespace,
        $entity,
        $skeletonsPath = null,
        $targetPath    = null,
        array $excludedSkeletons
    )
    {
        $skeletonsPath = $skeletonsPath ?: $this->skeletonsPath;
        $targetPath    = $targetPath ?: $this->targetPath;
        $finder        = new Finder();
        $inflector     = new Inflector(array(
            'MajoraVendor'    => $vendor,
            'MajoraNamespace' => $namespace,
            'MajoraEntity'    => $entity,
        ));
        $modifiersStack = array();

        // create file tree
        $finder->in($skeletonsPath);
        array_map(
            function($excludedSkeleton) use ($finder) {
                $finder->notPath($excludedSkeleton);
            },
            $excludedSkeletons
        );
        foreach ($finder as $templateFile) {

            $generatedFile = new SplFileInfo(
                $generatedFilePath = $this->generatePath(
                    $templateFile,
                    realpath($skeletonsPath),
                    realpath($targetPath),
                    $inflector
                ),
                '',
                ''
            );

            // directory ---------------------------------------------------------
            if ($templateFile->isDir()) {
                $this->generateDir($generatedFilePath);

                continue;
            }

            // file --------------------------------------------------------------
            $fileContent = $inflector->translate($templateFile->getContents());

            // always read template file metadata
            $metadata    = $this->getMetadata($fileContent);

            $forceGeneration = !empty($metadata['force_generation']);
            unset($metadata['force_generation']);

            $modifyContent = count($metadata);

            $alreadyGenerated = $this->filesystem->exists($generatedFilePath);

            // contents needs to be updated ?
            if ($alreadyGenerated && $modifyContent) {
                $fileContent = $generatedFile->getContents();
            }

            // stack content modifiers
            $modifiersStack[] = array(
                array($this, 'modify'),
                array($generatedFile, $templateFile, $metadata, $inflector)
            );

            // have to touch existing file ?
            if ($alreadyGenerated && !$forceGeneration) {
                continue;
            }

            $this->filesystem->dumpFile($generatedFilePath, $fileContent);

            $this->logger->info(sprintf('file %s: %s',
                $forceGeneration ? 'forced' : 'created',
                $generatedFilePath
            ));
        }

        // unstack all modifiers
        foreach ($modifiersStack as $modifierCallback) {
            call_user_func_array($modifierCallback[0], $modifierCallback[1]);
        }
    }
712312
protected function setLayout($sLayoutName)
    {
        if (is_null($this->view)) {
            throw new Exception("It's unable to set Layout without View.");
        }
        $this->layout = ViewFactory::createLayout($sLayoutName, $this->view);
    }
772071
public function setPropertyFile($propertyFile)
    {
        if (!file_exists($this->getDirectory() . DIRECTORY_SEPARATOR . $propertyFile)) {
            throw new \Exception(Lang::get('property_file_missing'));
        }

        $this->propertyFile = $propertyFile;
    }
1338858
public void initializeRelativePath(ServletRequest request, String relativeTo) 
    {
        if ( relativeTo == null )
        {
            relativeTo = _relativeTo;
        }

        if ( relativeTo == null ) return;

        assert ! relativeTo.endsWith("/") : relativeTo;
        String path = getPath();
         
        // If this is a local (relative) path, prefix it with the given 'relativeTo' path, and save a flag.
        // We save this flag in a local variable because the Forward object may be saved/restored for use again.
        if (! getContextRelative() && ! FileUtils.isAbsoluteURI(path)) {
            assert path.startsWith("/") : path;
            setPath(relativeTo + path);
            setContextRelative(true);
            _outsidePageFlowDirectory = true;
        }
        
        // Store a flag in the request that will prevent another page flow from being initialized implicitly because
        // we're hitting a path within it.  We want to stay in the context of the current page flow.
        if (_outsidePageFlowDirectory) {
            PageFlowRequestWrapper.get(request).setStayInCurrentModule(true);
        }
    }
721252
public function setErrorTemplate($errorTemplate, $engine = null)
    {
        if (!\is_string($errorTemplate)) {
            throw new \InvalidArgumentException('Please use string as template name (Example: "folder.file").');
        }

        $this->errorTemplate = $errorTemplate;

        if ($engine) {
            $this->setEngine($engine);
        }
    }
520844
protected final function BuiltInTemplateFile()
    {
        $class = new \ReflectionClass($this);
        $classFile = Str::Replace('\\', '/', $class->getFileName());
        $templatePath = Str::Replace('/Modules/', '/Templates/', $classFile);
        return Path::AddExtension($templatePath, 'phtml', true);
    }
1202991
public function setPath( $path )
	{
#		if( $path && !file_exists( $path ) )
#			throw new RuntimeException( 'Invalid path' );
		$path	= str_replace( DIRECTORY_SEPARATOR, "/", $path );
		$path	= preg_replace( "@(.+)/$@", "\\1", $path )."/";
		$this->path	= $path;
	}
881383
public function compile($path = null)
    {
        if ($path) {
            $this->setPath($path);
        }

        if (!is_null($this->cachePath)) {
            if (!is_file($path)) {
                throw new \RuntimeException("File does not exist at path {$path}");
            }

            file_put_contents(
                $this->getCompiledPath($path),
                $this->compileString(file_get_contents($path))
            );
        }
    }
93055
public function setTemplateDir($templatesDirectory)
    {
        if ($templatesDirectory && !in_array($templatesDirectory, $this->_aTemplateDir)) {
            $this->_aTemplateDir[] = $templatesDirectory;
        }
    }
19261
public function setTemplate($tpl, $clearParams=true)
    {
        if ($clearParams) {
            $this->clearParams();
        }
        $this->templateFile = $this->templatesPath.$tpl.'.tpl.php';
    }
1098430
public function setPath($path, $recursive = true)
    {
        if (!is_string($path) || preg_match(NodeInterface::MATCH_PATTERN_PATH, $path) !== 1) {
            throw new \InvalidArgumentException('Invalid path "' . $path . '" (a path must be a valid string, be absolute (starting with a slash) and contain only the allowed characters).', 1284369857);
        }

        if ($path === $this->path) {
            return;
        }

        if ($recursive === true) {
            foreach ($this->getChildNodeData() as $childNodeData) {
                $childNodeData->setPath(NodePaths::addNodePathSegment($path, $childNodeData->getName()));
            }
        }

        $pathBeforeChange = $this->path;

        $this->path = $path;
        $this->calculatePathHash();
        $this->parentPath = NodePaths::getParentPath($path);
        $this->calculateParentPathHash();
        $this->depth = NodePaths::getPathDepth($path);

        if ($pathBeforeChange !== null) {
            // this method is called both for changing the path AND in the constructor of Node; so we only want to do
            // these things below if called OUTSIDE a constructor.
            $this->emitNodePathChanged($this);
            $this->addOrUpdate();
        }
    }
972842
public function addTemplateFile($urlOfFile,$templateFileType)
    {
        $file = new File($this->getContext(),$this->getResourcePath());
        $qry = new InvokePostMethodQuery(
            $this->getResourcePath(),
            "addTemplateFile",
            array(
                "urlOfFile" => $urlOfFile,
                "templateFileType" => (int)$templateFileType
            )
        );
        $this->getContext()->addQuery($qry,$file);
        return $file;
    }