Webiny\Component\Bootstrap\ApplicationClasses\Application::getComponentConfig PHP Method

getComponentConfig() public method

Get a component configuration (configurations from within the environment folder).
public getComponentConfig ( string $component, string $query = '', null $default = null ) : mixed | ConfigObject
$component string Component name.
$query string Query inside the component config.
$default null Default value which should be returned if query has no matches.
return mixed | Webiny\Component\Config\ConfigObject
    public function getComponentConfig($component, $query = '', $default = null)
    {
        $componentConfig = $this->environment->getComponentConfigs()->get($component, false);
        if (!$componentConfig) {
            return $default;
        }
        if ($query == '') {
            return $componentConfig;
        }
        return $componentConfig->get($query, $default);
    }

Usage Example

Example #1
0
 public function testGetComponentConfigQueryDefault()
 {
     $env = Environment::getInstance();
     $env->initializeEnvironment(__DIR__ . '/../DemoApp/');
     $app = new Application($env);
     $result = $app->getComponentConfig('Router', 'Testing', 'default');
     $this->assertSame('default', $result);
 }