Bluz\Config\Config::getModuleData PHP Method

getModuleData() public method

Return module configuration by section
public getModuleData ( string $module, string $section = null ) : mixed
$module string
$section string
return mixed
    public function getModuleData($module, $section = null)
    {
        if (!isset($this->modules[$module])) {
            $this->modules[$module] = $this->loadFile($this->path . '/modules/' . $module . '/config.php');
            if (is_null($this->config)) {
                $this->init();
            }
            if (isset($this->config['module.' . $module])) {
                $this->modules[$module] = array_replace_recursive($this->modules[$module], $this->config['module.' . $module]);
            }
        }
        if (!is_null($section)) {
            return $this->modules[$module][$section] ?? null;
        } else {
            return $this->modules[$module];
        }
    }

Usage Example

Example #1
0
 /**
  * @covers Bluz\Config\Config::getModuleData
  */
 public function testGetModuleDataBySectionWithEnvironment()
 {
     $this->config->setPath($this->path);
     $this->config->setEnvironment('testing');
     $this->assertEquals('baz', $this->config->getModuleData('index', 'foo'));
 }