Load a profile from file.

@var $filepath string
343519
public static function loadFromFile($filepath)
  {
    $info = Yaml::parseFile($filepath);
    $name = str_replace('.profile.yml', '', pathinfo($filepath, PATHINFO_BASENAME));

    $profile = new static();
    $profile->setTitle($info['title'])
            ->setName($name)
            ->setFilepath($filepath);

    if (isset($info['description'])) {
      $profile->setDescription($info['description']);
    }

    if (isset($info['policies'])) {
      $v21_keys = ['parameters', 'severity'];
      foreach ($info['policies'] as $name => $metadata) {
        // Check for v2.0.x style profiles.
        if (!empty($metadata) && !count(array_intersect($v21_keys, array_keys($metadata)))) {
          throw new \Exception("{$info['title']} is a v2.0.x profile. Please upgrade $filepath to v2.2.x schema.");
        }
        $weight = array_search($name, array_keys($info['policies']));
        $profile->addPolicyDefinition(PolicyDefinition::createFromProfile($name, $weight, $metadata));
      }
    }

    if (isset($info['excluded_policies']) && is_array($info['excluded_policies'])) {
      $profile->addExcludedPolicies($info['excluded_policies']);
    }

    if (isset($info['include'])) {
      foreach ($info['include'] as $name) {
        $include = ProfileSource::loadProfileByName($name);
        $profile->addInclude($include);
      }
    }

    if (isset($info['format'])) {
      foreach ($info['format'] as $format => $options) {
        $profile->addFormatOptions(Format::create($format, $options));
      }
    }

    return $profile;
  }
653275
public function resolveProfilePath($path, $profile)
    {
        $path = $this->resolvePath($path);
        return preg_replace_callback('|\[\[([\w\_/]+)\]\]|', function ($matches) use ($profile) {
            $name = $matches[1];
            switch ($name) {
                case 'profile':
                    return $profile;
            }
            return '[[' . $name . ']]';
        }, $path);
    }
219288
public function load($filepath = null, $preview = false)
    {
        Environment::increaseTimeLimitTo(3600);
        Environment::increaseMemoryLimitTo('512M');

        $this->mappableFields_cache = $this->getMappableColumns();
        return $this->processAll($filepath, $preview);
    }
619165
public static function parse(string $filePath): FilePathInterface
    {
        if (!self::myFilePathParse(
            DIRECTORY_SEPARATOR,
            $filePath,
            function ($p, $d, &$e) {
                return self::myPartValidator($p, $d, $e);
            },
            null,
            $isAbsolute,
            $aboveBaseLevel,
            $drive,
            $directoryParts,
            $filename,
            $error)
        ) {
            throw new FilePathInvalidArgumentException('File path "' . $filePath . '" is invalid: ' . $error);
        }

        return new self($isAbsolute, $aboveBaseLevel, $drive, $directoryParts, $filename);
    }
8144
public function loadFile($filePath) {
        require_once (substr($filePath, 0, 1) != '/' && substr($filePath, 1, 1) != ':')
            ? $this->basePath . DIRECTORY_SEPARATOR . $filePath : $filePath;
    }
255699
public function download($filePath)
    {
        $urlParts = parse_url($filePath);
        $rootDir = null;

        if (!is_null($this->rootDir)) {
            $rootDir = $this->rootDir;
        } else {
            $rootDir = CYGNITE_BASE.DS;
        }

        $filePath = $rootDir.str_replace('/', DS, str_replace('/'.ROOTDIR.'/', '', $urlParts['path']));

        if (is_null($this->filePath) && $filePath != '') {
            $this->filePath = $filePath;
        }

        $isSetFileType = $this->setMimeType($this->filePath);

        if ($isSetFileType) {
            $this->setHeaders();
        }
        //$this->filePath
    }
51656
public function readFileFunc($filepath)
    {
        /** @var UniformResourceLocator $locator */
        $locator = $this->grav['locator'];

        if ($locator->isStream($filepath)) {
            $filepath = $locator->findResource($filepath);
        }

        if ($filepath && file_exists($filepath)) {
            return file_get_contents($filepath);
        }

        return false;
    }
1199534
protected static function loadKeyFile(string $filePath): HiddenString
    {
        $fileData = \file_get_contents($filePath);
        if ($fileData === false) {
            // @codeCoverageIgnoreStart
            throw new CannotPerformOperation(
                'Cannot load key from file: '. $filePath
            );
            // @codeCoverageIgnoreEnd
        }
        $data = Hex::decode($fileData);
        \sodium_memzero($fileData);
        return new HiddenString(
            self::getKeyDataFromString($data)
        );
    }
774962
public function loadFile($filepath)
    {
        $file = realpath($filepath);
        if ($file === false) {
            throw new JitException("Error, the file `'{$filepath}'` doesn't exist.");
        }
        if (!$this->_patchers) {
            require $file;
            return true;
        }

        if (!$cached = $this->cached($file)) {
            $code = file_get_contents($file);
            $timestamp = filemtime($file);

            $rewrited = $this->_patchers->process($code, $file);
            $cached = $this->cache($file, $rewrited, max($timestamp, $this->_watchedTimestamp) + 1);
        }
        $includePath = get_include_path();
        set_include_path($includePath ? $includePath . ':' . dirname($file) : dirname($file));
        require $cached;
        restore_include_path();
        return true;
    }
843429
def load_creds_file(self, path, profile=None):
        """"""
        config_cls = self.get_creds_reader()
        return config_cls.load_config(self, path, profile=profile)
221956
public function readFile($filePath = null, array $options = [])
    {
        $filePath = empty($filePath)
            ? $this->filePath
            : $filePath;

        $result = new ArrayIterator();

        if (false !== ($contents = json_decode(file_get_contents($filePath), true))) {
            if (json_last_error() === JSON_ERROR_NONE) {
                foreach ($contents as $content) {
                    $result[] = new SplArrayObject($content);
                }
            }
        }

        return $result;
    }
270232
static function load($filename)
	{
		if (isset(self::$stack[$filename])) return self::$stack[$filename];
		$path = self::get("apppath") . "config" . DS . $filename;
		if (!file_exists($path)) throw new \Exception("Config file '$filename' not found'");
		$config_data = include($path);
		self::set($filename, $config_data);
		return $config_data;
	}
1369692
protected function loadConfigFile(string $fileKey, string $filePath)
    {
        $fileExtension = pathinfo($filePath, PATHINFO_EXTENSION);

        if ($fileExtension === 'json') {
            $this->loadJsonConfigFile($fileKey, $filePath);
            return;
        }

        if ($fileExtension === 'php') {
            $this->loadPhpConfigFile($fileKey, $filePath);
            return;
        }

        //@TODO : YAML
    }
1276972
protected function getFileAsset($filePath)
    {
        $file = new \SplFileInfo($filePath);

        if (!$file->isReadable() || $file->isDir()) {
            return null;
        }

        $filePath = $file->getRealPath();

        return new FileAsset($filePath);
    }
659337
public function loadFile($filePath)
    {
        if ($filePath instanceof \SplFileInfo) {
            $filePath = $filePath->getRealPath();
        }

        if (is_file($filePath)) {
            return $this->loadString(file_get_contents($filePath));
        }

        return false;
    }
1053678
public static function loadContextFromFile(string $filePath): ContextInterface
    {
        if(!file_exists($filePath)){
            throw new Exception\FileNotFoundException('Context file not found: '.$filePath, 404, null, $filePath);
        }

        $contents = file_get_contents($filePath);
        $context_array = json_decode($contents, true);

        if($context_array === null){
            throw new Exception\MalformedJsonException('JSON sintax error.');
        }

        return new self($context_array);
    }
712047
public function readFile($filePath = null, array $options = [])
    {
        $filePath = empty($filePath)
            ? $this->filePath
            : $filePath;

        $result = new ArrayIterator();

        if (false !== ($xml = simplexml_load_file($filePath))) {
            $contents = json_decode(json_encode($xml), true); // force to array conversion

            if (count($contents) == 1) {
                $contents = reset($contents);
            }

            if (json_last_error() === JSON_ERROR_NONE) {
                foreach ($contents as $content) {
                    $result[] = new SplArrayObject($content);
                }
            }
        }

        return $result;
    }