Get config from xml file

@param SplFileInfo $file XML file

@return array Smarty Filter module configuration
177634
protected function parseXml(SplFileInfo $file)
    {
        $dom = XmlUtils::loadFile($file, realpath(dirname(__DIR__) . DS . 'Schema' . DS . 'smarty_filter.xsd'));
        /** @var \Symfony\Component\DependencyInjection\SimpleXMLElement $xml */
        $xml = simplexml_import_dom($dom, '\\Symfony\\Component\\DependencyInjection\\SimpleXMLElement');

        $parsedConfig = [];
        /** @var \Symfony\Component\DependencyInjection\SimpleXMLElement $smartyFilterDefinition */
        foreach ($xml->smartyfilter as $smartyFilterDefinition) {
            $descriptive = [];
            /** @var \Symfony\Component\DependencyInjection\SimpleXMLElement $descriptiveDefinition */
            foreach ($smartyFilterDefinition->descriptive as $descriptiveDefinition) {
                $descriptive[] = [
                    'locale' => $descriptiveDefinition->getAttributeAsPhp('locale'),
                    'title' => (string)$descriptiveDefinition->title,
                    'description' => (string)$descriptiveDefinition->description,
                    'type' => (string)$descriptiveDefinition->type
                ];
            }

            $parsedConfig['smarty_filter'][] = [
                'code' => $smartyFilterDefinition->getAttributeAsPhp('code'),
                'descriptive' => $descriptive
            ];
        }


        return $parsedConfig;
    }
99808
protected function parse(\SplFileInfo $file): array
    {
        try {
            $config = (new Parser())->parseFile($file->getRealPath());
        } catch (ParseException $e) {
            throw new ConfigurationParseException('Unable to parse config file: ' . $e->getMessage());
        }

        return $config;
    }
166749
public function filter(\SPLFileInfo $file)
    {
        foreach ($this->filterlist as $filter) {
            if (! $filter->filter($file)) {
                return false;
            }
        }
        return true;
    }
210444
protected function parseConfig($file)
    {
        $namespace = '';
        $directory = '';

        $config = file_get_contents($file);
        switch (pathinfo($file, PATHINFO_EXTENSION)) {
            case 'yml':
            case 'yaml':
                $config = Yaml::parse($config);
                if (isset($config['migrations_namespace'])) {
                    $namespace = $config['migrations_namespace'];
                }
                if (isset($config['migrations_directory'])) {
                    $directory = $config['migrations_directory'];
                }
                break;
            case 'xml':
                $doc = new \DOMDocument();
                $doc->loadXML($config);
                $list = $doc->getElementsByTagName('migrations-namespace');
                if ($list->length) {
                    $namespace = $list->item(0)->nodeValue;
                }
                $list = $doc->getElementsByTagName('migrations-directory');
                if ($list->length) {
                    $directory = $list->item(0)->nodeValue;
                }
                break;
        }

        return [
            'namespace' => $namespace && $namespace[0] == '\\' ? substr($namespace, 1) : $namespace,
            'directory' => $directory,
        ];
    }
218226
protected function wrapConfigurationContents(SplFileInfo $file, array $contents)
    {
        $key = $file->getBasename('.'.$file->getExtension());
        if (array_keys($contents) !== [$key] || !is_array($contents[$key])) {
            return [$key => $contents];
        } elseif (array_keys($contents) === ['rocketeer']) {
            return $contents['rocketeer'];
        }

        return $contents;
    }
1348252
protected function match(SplFileInfo $file): bool
    {
        return $file->isFile() &&
                $this->hasExtension($file) &&
                $this->instanceOf($file)
        ;
    }
1031215
public function getConfigFile($file = null)
    {
        $file = $file ?: $this->configFile;

        return file_exists($file) ? $file : $this->getConfigFileStub();
    }
860550
public function getMimeType(\SplFileInfo $file)
    {
        $fileInfo = finfo_open(FILEINFO_MIME_TYPE);
        $mimeType = finfo_file($fileInfo, $file->getPathname());
        finfo_close($fileInfo);

        return $mimeType;
    }
1071868
protected function getFilePath(SplFileInfo $file)
	{
		$location = $file->getPathname();
		$path = $this->removePathPrefix($location);

		return \trim(\str_replace('\\', '/', $path), '/');
	}
508214
protected function isAllowFile(SplFileInfo $file)
    {
        return in_array(strtolower(pathinfo($file->getFilename(), PATHINFO_EXTENSION)), $this->allow_ext);
    }
1006992
private function getServiceDefaults(\DOMDocument $xml, $file)
    {
        $xpath = new \DOMXPath($xml);
        $xpath->registerNamespace('container', self::NS);

        if (null === $defaultsNode = $xpath->query('//container:services/container:defaults')->item(0)) {
            return array();
        }
        $defaults = array(
            'tags' => $this->getChildren($defaultsNode, 'tag'),
            'bind' => array_map(function ($v) { return new BoundArgument($v); }, $this->getArgumentsAsPhp($defaultsNode, 'bind', $file)),
        );

        foreach ($defaults['tags'] as $tag) {
            if ('' === $tag->getAttribute('name')) {
                throw new InvalidArgumentException(sprintf('The tag name for tag "<defaults>" in %s must be a non-empty string.', $file));
            }
        }

        if ($defaultsNode->hasAttribute('autowire')) {
            $defaults['autowire'] = XmlUtils::phpize($defaultsNode->getAttribute('autowire'));
        }
        if ($defaultsNode->hasAttribute('public')) {
            $defaults['public'] = XmlUtils::phpize($defaultsNode->getAttribute('public'));
        }
        if ($defaultsNode->hasAttribute('autoconfigure')) {
            $defaults['autoconfigure'] = XmlUtils::phpize($defaultsNode->getAttribute('autoconfigure'));
        }

        return $defaults;
    }
886343
public static function getName(SplFileInfo $file)
    {
        $name = $file->getRelativePathname();

        return substr($name, 0, strrpos($name, '.'));
    }
336169
public function getConfigVar($file)
    {
        $_config = [];

        $absFile = $this->appPath . 'config/' . $this->appStatus . '/' . $file . '.cfg.php';

        if (file_exists($absFile)) {
            include $absFile;
        }
        return $_config;
    }
30116
protected function decodeFile(\SplFileInfo $file, $strict = true)
    {
        $mimeType = $file->getExtension();

        $this->checkAndAddDefaultDecoder($mimeType);

        if ($this->isSupportedMimeType($mimeType)) {

            if (is_readable($file->getPathname())) {
                $data = $this->getFileContents($file);
            } else {
                if ($strict) {
                    throw new \Exception("File not found: {$file->getPathname()}");
                } else {
                    return [];
                }
            }

            return $this->decoders[$mimeType]->decode($data);
        }

        $this->unsupportedFiles[] = $file->getFilename();
        return false;
    }
770203
public function resolve($file)
    {
        $info = null;

        $this->rewind();
        foreach (clone $this as $path) {
            $info = new SplFileInfo(rtrim($path, '/') . '/' . ltrim($file, '/'));

            if ($info->isDir() || $info->isFile() || $info->isLink()) {
                break;
            }
        }

        return ($info)? $info->getPathname() : null;
    }
293592
static function fromYaml($file)
    {
        if (!file_exists($file)) {
            throw new \InvalidArgumentException("Config file '$file' not found.");
        }

        $values = Yaml::parse(file_get_contents($file));
        $config = new static($values, $file);

        return $config;
    }
384588
protected function loadFile($file)
    {
        if (class_exists('Symfony\Component\Config\Util\XmlUtils')) {
            $dom = XmlUtils::loadFile($file);
            $this->validate($dom);

            return $dom;
        }

        return parent::loadFile($file);
    }