Expands YAML placeholders in a given file, using config object.

@param string $filename
The file in which placeholders should be expanded.
761174
public function expandFileProperties($filename) {
    $expanded_contents = Expander::expandArrayProperties(file($filename), $this->export());
    file_put_contents($filename, implode("", $expanded_contents));
  }
847769
public function addPHPConfig($filename)
    {
        $filename = trim($filename);
        
        if (strlen($filename) === 0) {
            throw new ConfiguratorException("Zero length filename is bogus.");
        }
        
        if (file_exists($filename) === false) {
            throw new ConfiguratorException("File `$filename` does not exist.");
        }
        
        ob_start();
        require($filename);
        $contents = ob_get_contents();
        ob_end_clean();

        if (strlen($contents) !== 0) {
            $message = sprintf(
                "Filename `%s` output some characters. Please check it is a valid PHP file.\n",
                $filename
            );

            throw new ConfiguratorException($message);
        }

        if (isset($default) === true) {
            $this->configuratorData->addConfigDefault($default);
        }

        foreach ($this->environmentList as $environment) {
            if (isset($$environment) === true) {
                $this->configuratorData->addConfigEnvironment($$environment);
            }
        }

        if (isset($override) === true) {
            $this->configuratorData->addConfigOverride($override);
        }

        if (isset($evaluate) === true) {
            $calculatedValues = $evaluate($this->configuratorData->getConfig(), $this->environment);
            $this->configuratorData->addConfigOverride($calculatedValues);
        }
    }
500338
public function rename( $fileName )
	{
		if( !$fileName )
			throw new InvalidArgumentException( 'No File Name given.' );
		$result	= @rename( $this->fileName, $fileName );
		if( $result === FALSE )
			throw new RuntimeException( 'File "'.$this->fileName.'" could not been renamed.' );
		$this->__construct( $fileName );
		return $result;
	}
1220378
protected function validateFileName($fileName = null)
    {
        if ($fileName === null) {
            $fileName = $this->fileName;
        }

        $fileName = trim($fileName);

        if (!strlen($fileName)) {
            throw new ValidationException(['fileName' =>
                Lang::get('cms::lang.cms_object.file_name_required', [
                    'allowed' => implode(', ', $this->allowedExtensions),
                    'invalid' => pathinfo($fileName, PATHINFO_EXTENSION)
                ])
            ]);
        }

        if (!FileHelper::validateExtension($fileName, $this->allowedExtensions, false)) {
            throw new ValidationException(['fileName' =>
                Lang::get('cms::lang.cms_object.invalid_file_extension', [
                    'allowed' => implode(', ', $this->allowedExtensions),
                    'invalid' => pathinfo($fileName, PATHINFO_EXTENSION)
                ])
            ]);
        }

        if (!FileHelper::validatePath($fileName, null)) {
            throw new ValidationException(['fileName' =>
                Lang::get('cms::lang.cms_object.invalid_file', [
                    'name' => $fileName
                ])
            ]);
        }
    }
651660
public function setFilename($filename)
    {
        $filename = $this->filterFilename($filename);

        // Check existing folder path
        $folder = '';
        $parent = $this->Parent();
        if ($parent && $parent->exists()) {
            $folder = $parent->getFilename();
        }

        // Detect change in foldername
        $newFolder = ltrim(dirname(trim($filename, '/')), '.');
        if ($folder !== $newFolder) {
            if (!$newFolder) {
                $this->ParentID = 0;
            } else {
                $parent = Folder::find_or_make($newFolder);
                $this->ParentID = $parent->ID;
            }
        }

        // Update base name
        $this->Name = basename($filename);
        return $this;
    }
221576
static function applyStorageFilePermissions( $filename )
    {
        $siteConfig = eZINI::instance( 'site.ini' );
        $filePermissions = $siteConfig->variable( 'FileSettings', 'StorageFilePermissions');
        chmod( $filename, octdec( $filePermissions ) );
    }
1341803
public function setCompileFile($filename)
    {
        $filename = (($this->compileFileNameMd5) ? md5(md5($filename)) : $filename);
        $this->templateCompileFile = $this->compilePath . $filename . $this->compileFileSuffix;
    }
6557
public static function load(string $filename) {
		if(class_exists(Dotenv::class)) {
			$dotenv = new Dotenv($filename);
			$dotenv->load();
		}
	}
301216
public function openFile($filename)
    {
        $this->file = file_get_contents($this->absolutizePath($filename));
        $this->filepath = $filename;
    }
1188920
public static function getYamlContents(string $filename)
    {
        $result = null;
        if (file_exists($filename)) {
            $result = Yaml::parse(file_get_contents($filename));
        }
        return $result;
    }
197783
public function getConfigByFilename(string $filename)
    {
        if (!isset($this->config[$filename])) {
            throw new Exception(
                'The file '.$filename.' has not been found',
                $this::ERR_FILE_NOT_FOUND
            );
        }
        
        return $this->config[$filename];
    }
143110
public function rename($filename)
    {
        if ($this->exists() && !@rename($this->filename, $filename)) {
            return false;
        }

        unset(static::$instances[$this->filename]);
        static::$instances[$filename] = $this;

        $this->filename = $filename;

        return true;
    }
986184
protected function loadYamlFile( $fileName )
	{
		$array	= FS_File_YAML_Reader::load( $fileName );
		foreach( $array as $sectionName => $sectionData )
			foreach( $sectionData as $key => $value )
				$this->pairs[$sectionName.".".$key]	= $value;
	}
727305
private function doPrepend(ContainerBuilder $container, string $fileName, string $configName): void
    {
        $configFile = __DIR__ . '/../Resources/config/' . $fileName;
        $config = Yaml::parse((string) file_get_contents($configFile));
        $container->prependExtensionConfig($configName, $config);
        $container->addResource(new FileResource($configFile));
    }
1272871
public function load($filename)
    {
        $this->filename = $filename;
        $this->readXML($this->filename);
        $this->configure($this->xml->value);
        $this->loadUserDatatypes();
        $this->parse();
    }
966555
protected static function getConfFromContents($contents, $filename = '(.yml)')
    {
        if (self::$params) {
            $template = new Template($contents, '%', '%');
            $template->setVars(self::$params);
            $contents = $template->produce();
        }

        try {
            return Yaml::parse($contents);
        } catch (ParseException $exception) {
            throw new ConfigurationException(
                sprintf(
                    "Error loading Yaml config from `%s`\n \n%s\nRead more about Yaml format https://goo.gl/9UPuEC",
                    $filename,
                    $exception->getMessage()
                )
            );
        }
    }
499912
public static function append_suffix($filename) {
        debugging('The function repository::append_suffix() has been deprecated. Use repository::get_unused_filename() instead.',
            DEBUG_DEVELOPER);
        $pathinfo = pathinfo($filename);
        if (empty($pathinfo['extension'])) {
            return $filename . RENAME_SUFFIX;
        } else {
            return $pathinfo['filename'] . RENAME_SUFFIX . '.' . $pathinfo['extension'];
        }
    }