FOF30\Configuration\Configuration::parseComponentArea PHP Method

parseComponentArea() protected method

Parses the configuration options of a specific component area
protected parseComponentArea ( string $area, boolean $userConfig = false ) : array
$area string Which area to parse (frontend, backend, cli)
$userConfig boolean When true the user configuration (fof.user.xml) file will be read
return array A hash array with the configuration data
    protected function parseComponentArea($area, $userConfig = false)
    {
        $component = $this->container->componentName;
        // Initialise the return array
        $ret = array();
        // Get the folders of the component
        $componentPaths = $this->container->platform->getComponentBaseDirs($component);
        $filesystem = $this->container->filesystem;
        $path = $componentPaths['admin'];
        if (isset($this->container['backEndPath'])) {
            $path = $this->container['backEndPath'];
        }
        // This line unfortunately doesn't work with Unit Tests because JPath depends on the JPATH_SITE constant :(
        // $path = $filesystem->pathCheck($path);
        // Check that the path exists
        if (!$filesystem->folderExists($path)) {
            return $ret;
        }
        // Read the filename if it exists
        $filename = $path . '/fof.xml';
        if ($userConfig) {
            $filename = $path . '/fof.user.xml';
        }
        if (!$filesystem->fileExists($filename) && !file_exists($filename)) {
            return $ret;
        }
        $data = file_get_contents($filename);
        // Load the XML data in a SimpleXMLElement object
        $xml = simplexml_load_string($data);
        if (!$xml instanceof \SimpleXMLElement) {
            return $ret;
        }
        // Get this area's data
        $areaData = $xml->xpath('//' . $area);
        if (empty($areaData)) {
            return $ret;
        }
        $xml = array_shift($areaData);
        // Parse individual configuration domains
        $domains = $this->getDomains();
        foreach ($domains as $dom) {
            $class = '\\FOF30\\Configuration\\Domain\\' . ucfirst($dom);
            if (class_exists($class, true)) {
                /** @var   \FOF30\Configuration\Domain\DomainInterface  $o */
                $o = new $class();
                $o->parseDomain($xml, $ret);
            }
        }
        // Finally, return the result
        return $ret;
    }