Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Static Public Member Functions | List of all members
Configuration Class Reference

Static Public Member Functions

static build ($mainConfigFile)

Detailed Description

Gentics Portal.Node PHP Author & Copyright (c) by Gentics Software GmbH sales.nosp@m.@gen.nosp@m.tics..nosp@m.com http://www.gentics.com Licenses can be found in the LICENSE.txt file in the root-folder of this installation You must not use this software without a valid license agreement.

Class for preparing configuration.

Definition at line 12 of file Configuration.php.

Member Function Documentation

static Configuration::build (   $mainConfigFile)
static

Build configuration file. Custom user modules support implemented here. Example: Module placed in /common/modules/comments its config in /frontend/config/comments.php Custom copy placed in /common/custom/comments its config in /custom/config/comments.php

To activate module in /config/main.php add 'modules' => array( 'comments', ) By default common module will be loaded, To load custom add '_active' => true to its configuration file

Parameters
string$mainConfigFileconfiguration file path
Exceptions
Exception
Returns
array result configuration file

Definition at line 32 of file Configuration.php.

{
$mainConfigFile = realpath($mainConfigFile);
$customConfigFile = realpath(dirname(__FILE__) . '/../../custom/config/client_main.php');
//check if configFile not outside app directory
if ($mainConfigFile) {
$appDir = realpath(dirname(__FILE__) . '/../../');
if (strpos($mainConfigFile, $appDir) !== 0) {
throw new Exception('Config file error');
}
}
$mainConfig = include $mainConfigFile;
$customConfig = include $customConfigFile;
foreach ($customConfig['modules'] as $key => $cConfig) {
$name = is_integer($key) ? $cConfig : $key;
$cConfig = !is_array($cConfig) ? array() : $cConfig;
if (isset($mainConfig['modules'][$name])) {
$mainConfig['modules'][$name] = CMap::mergeArray($mainConfig['modules'][$name], $cConfig);
} else {
$mainConfig['modules'][$name] = $cConfig;
if (($k = array_search($name, $mainConfig['modules'])) !== false) {
unset($mainConfig['modules'][$k]);
}
}
unset($customConfig['modules'][$key]);
}
foreach ($customConfig['components'] as $key => $cConfig) {
$name = is_integer($key) ? $cConfig : $key;
$cConfig = !is_array($cConfig) ? array() : $cConfig;
if (isset($mainConfig['components'][$name])) {
$mainConfig['components'][$name] = CMap::mergeArray($mainConfig['components'][$name], $cConfig);
} else {
$mainConfig['components'][$name] = $cConfig;
if (($k = array_search($name, $mainConfig['components'])) !== false) {
unset($mainConfig['components'][$k]);
}
}
unset($customConfig['components'][$key]);
}
$resultConfig = CMap::mergeArray($mainConfig, $customConfig);
return $resultConfig;
}

The documentation for this class was generated from the following file: