load

@param string $file
@param string $format
@param string $package

@return static
@throws \ReflectionException
963786
public function loadFile($file, $format = 'ini', $package = null)
    {
        $config = $this->config;

        $format = $format ?: $config->get('language.format', 'ini');

        $default = $config['language.default'] ?: 'en-GB';
        $locale  = $config['language.locale'] ?: 'en-GB';

        $ext = $format == 'yaml' ? 'yml' : $format;

        $default = LanguageNormalize::toLanguageTag($default);
        $locale  = LanguageNormalize::toLanguageTag($locale);

        // If package name exists, we load package language first, that global can override it.
        if (is_string($package)) {
            $package = $this->packageResolver->getPackage($package);
        }

        if ($package instanceof AbstractPackage) {
            $path = $package->getDir() . '/Resources/language/%s/%s.%s';

            // Get Package language
            if (!$config->get('language.debug') || $locale == $default) {
                $this->loadLanguageFile(sprintf($path, $default, $file, $ext), $format);
            }

            // If locale not equals default locale, load it to override default
            if ($locale != $default) {
                $this->loadLanguageFile(sprintf($path, $locale, $file, $format), $format);
            }
        }

        // Get Global language
        $path = $config->get('path.languages') . '/%s/%s.%s';

        if (!$config->get('language.debug') || $locale == $default) {
            $this->loadLanguageFile(sprintf($path, $default, $file, $format), $format);
        }

        // If locale not equals default locale, load it to override default
        if ($locale != $default) {
            $this->loadLanguageFile(sprintf($path, $locale, $file, $format), $format);
        }

        return $this;
    }
362461
public function load($file, $type = null)
    {
        $path = $this->locator->locate($file);

        if (!stream_is_local($path)) {
            throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $path));
        }

        if (!file_exists($path)) {
            throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path));
        }

        if (null === $this->yamlParser) {
            $this->yamlParser = new YamlParser;
        }

        try {
            $parsedConfig = $this->yamlParser->parse(file_get_contents($path));
        } catch (ParseException $e) {
            throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
        }

        $collection = [];

        // empty file
        if (null === $parsedConfig) {
            return $collection;
        }

        // not an array
        if (!is_array($parsedConfig)) {
            throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path));
        }

        foreach ($parsedConfig as $name => $config) {
            $this->validate($config, $name, $path);

            if (isset($config['resource'])) {
                $this->parseImport($collection, $config, $path, $file);
            } else {
                $this->parseMetadata($collection, $name, $config);
            }
        }

        return $collection;
    }
362365
private function load($file)
    {
        if (null === $this->command) {
            $this->command = Yaml::parse($file);
        }
        return $this->command;
    }
252096
public static function loadAll($package = null, $format = 'ini')
    {
        if (!$package) {
            static::loadAllFromPath(WINDWALKER_RESOURCES . '/languages', $format);

            return;
        }

        if (is_string($package)) {
            $package = PackageHelper::getPackage($package);
        }

        $path = $package->getDir() . '/Resources/language';

        static::loadAllFromPath($path, $format, $package);
    }
513260
public function load(array $file, Filesystem $fileReader)
    {
        if ($this->checkFile($file, $fileReader, $type = 'json') == true) {
            $this->open($file, $fileReader);
            if ($this->checkContentsAreArray() == true) {
                return $this->rawContents;
            }
        }
    }
771915
public function load(array $file, Filesystem $fileReader)
    {
        $fileLoader = new $this->options->configurationFileLoaders[$file['type']]();
        $alias = $file['alias'];
        $data = $fileLoader->load($file, $fileReader);
        $this->data[$alias] = $data;
    }
1095984
public function load($file, $type = null)
    {
        $path    = $this->locator->locate($file);
        $content = $this->loadFile($path);

        // empty file
        if (null === $content) {
            return array();
        }

        // imports (Symfony)
        $content = $this->parseImports($content, $path);

        // @include (Zend)
        $content = $this->parseIncludes($content, $path);

        // not an array
        if (!is_array($content)) {
            throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $path));
        }

        return $content;
    }
643409
public function load($files)
    {
        if (!is_array($files)) {
            $files = [$files];
        }
        foreach ($files as $file) {
            $file = new File($file);
            $extName = $file->extName();
            if ($extName == 'json') {
                $data = json_decode($file->readAll(), true);
                if (!$data) {
                    throw new \Exception("File '{$file}' is not valid JSON");
                }
            } else {
                $data = require (string) $file;
            }
            $this->fromArray($data);
        }
    }
948036
public function load($file)
    {
        $loader = new PhpConfig();
        $templates = $loader->read($file);
        $this->add($templates);
    }
957936
public function load($file)
    {
        $resource = new ZipFileResource($file);

        $package = $resource->getXML('META-INF/container.xml');

        if (!$opfFile = (string) $package->rootfiles->rootfile['full-path']) {
            $ns = $package->getNamespaces();
            foreach ($ns as $key => $value) {
                $package->registerXPathNamespace($key, $value);
                $items = $package->xpath('//'. $key .':rootfile/@full-path');
                $opfFile = (string) $items[0]['full-path'];
            }
        }

        $data = $resource->get($opfFile);

        // all files referenced in the OPF are relative to it's directory
        if ('.' !== $dir = dirname($opfFile)) {
            $resource->setDirectory($dir);
        }

        $opfResource = new OpfResource($data, $resource);
        $package = $opfResource->bind();
        
        $package->opfDirectory = dirname($opfFile);
        
        if ($package->navigation->src->href) {
            $ncx = $resource->get($package->navigation->src->href);
            $ncxResource = new NcxResource($ncx);
            $package = $ncxResource->bind($package);
        }
        
        return $package;
    }
289780
private function loadPackageAssets($packageVariant, Package $package)
	{
		$variants = $package->getVariants();
		$requiredVariant = $variants[$packageVariant];

		if (isset($requiredVariant['scripts'])) {
			$scripts = [];
			foreach ($requiredVariant['scripts'] as $script) {
				$scripts[] = new Asset($package, $script);
			}
			$this->assetsLoader->addScripts($scripts);
		}

		if (isset($requiredVariant['styles'])) {
			$styles = [];
			foreach ($requiredVariant['styles'] as $style) {
				$styles[] = new Asset($package, $style);
			}
			$this->assetsLoader->addStyles($styles);
		}
	}
1228416
private static function loadPackage(string $package): stdClass {
    $language = new stdClass();
    if (!empty($package)) {
      $filename = null;
      if ($packageData = explode(":", $package)) {
        if (!empty($packageData[0])) {
          $filename .= Lang::$root[$packageData[0]];
        }
        if (!empty($packageData[1])) {
          $filename .= DIRECTORY_SEPARATOR . $packageData[1];
        }
        $pathaname = Lang::selectPackage($filename);
        if (file_exists($pathaname)) {
          $pathaname = Path::replaceOSSeparator($pathaname);
          $decode = json_decode(file_get_contents((new SplFileObject($pathaname, "r"))->getPathname()));
          $language = (JSON_ERROR_NONE == json_last_error()) ? $decode : $language;
        }
      }
    }
    return $language;
  }
720162
public function loadFile($file)
    {
        if (!file_exists($file)) {
            throw new LoaderException("Requested YAML file '{$file}' doesn't exist");
        }

        $contents = file_get_contents($file);

        if ($this->useSymfony) {
            try {
                // Apparently parser keeps references to the things it parses? As such, we want to create a new parser
                // each time (uch)
                $parser = new Parser();
                return $parser->parse($contents);
            } catch (ParseException $e) {
                throw new LoaderException("Could not load the YAML file '{$file}': ".$e->getMessage());
            }
        }

        $data = yaml_parse($contents);
        if (!is_array($data)) {
            throw new LoaderException("Requested YAML file '{$file}' does not parse to an array");
        }

        return $data;
    }
502219
protected function loadFile($file, $data, $once = false)
    {
        $file = $this->basePath.'/'.ltrim($file, '/\\');

        if(!file_exists($file))
            throw new \Exedra\Exception\NotFoundException("File [$file] not found");

        extract($data);

        if($once)
            return require_once $file;
        else
            return require $file;

    }
850333
protected function loadFile($file)
    {
        if (!stream_is_local($file)) {
            throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file));
        }

        if (!file_exists($file)) {
            throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file));
        }

        return Toml::Parse($file);
    }
631739
protected function load( $file ) {
		if ( ! file_exists( $file ) ) {
			throw new JsonFileNotFoundException( 'The required ' . basename( $file ) . ' file is missing.' );
		}

		$contents = file_get_contents( $file );
		$json = json_decode( $contents, true );
		$json_error = json_last_error();

		if ( $json_error !== JSON_ERROR_NONE ) {
			throw new JsonFileInvalidException( 'The required ' . basename( $file ) . ' file is not valid JSON (error code ' . $json_error . ').' );
		}

		return $json;
	}
332233
public static function loadFile($file, $format = null)
    {
        if (!isset($format)) {
            $ext = pathinfo($file, PATHINFO_EXTENSION);
            $format = ArrayHelper::fetch(self::$FORMATS, $ext);
            if (!isset($format)) {
                throw new \InvalidArgumentException("Cannot infer format from file '{$file}'");
            }
        }
        if ($format == 'json') {
            return json_decode(file_get_contents($file), true);
        } elseif ($format == 'yaml') {
            return Yaml::parse(file_get_contents($file));
        } elseif ($format == 'php') {
            return require($file);
        } else {
            throw new \InvalidArgumentException("Invalid format '{$format}'");
        }
    }