Merge another Zend_Config with this one. The items
in $merge will override the same named items in
the current config.
public merge ( Zend_Config $merge ) : Zend_Config | ||
$merge | Zend_Config | |
return | Zend_Config |
/** * Инициализация конфигурации */ protected function _initConfig() { $path = APPLICATION_PATH . '/../library/Zkernel/Application/configs'; $config = new Zend_Config(array(), true); $it = new DirectoryIterator($path); foreach ($it as $file) { if ($file->isFile()) { $fullpath = $path . '/' . $file; switch (substr(trim(strtolower($fullpath)), -3)) { case 'ini': $cfg = new Zend_Config_Ini($fullpath, $this->getEnvironment()); break; case 'xml': $cfg = new Zend_Config_Xml($fullpath, $this->getEnvironment()); break; default: throw new Zend_Config_Exception('Invalid format for config file'); break; } $config->merge($cfg); } } $config->merge(new Zend_Config($this->getOptions())); $this->setOptions($config->toArray()); }
/** * Combine the static info found in application.ini with the * dynamic info found in the Info table. * * @return void */ protected function _initConfig() { $this->bootstrap('db'); $this->bootstrap('locale'); if (!class_exists('Model_Info')) { return; } try { $staticConfig = Zend_Registry::get('config'); $infoModel = $this->_getInfoModel(); $dynamicConfig = $infoModel->fetchAsConfig(null, APPLICATION_ENV); // Very sneakily bypass 'readOnly' if ($staticConfig->readOnly()) { $staticConfig = new Zend_Config($staticConfig->toArray(), APPLICATION_ENV, true); } $staticConfig->merge($dynamicConfig); $staticConfig->setReadOnly(); Zend_Registry::set('config', $staticConfig); } catch (Exception $e) { $msg = $e->getMessage(); if (strpos($msg, 'Unknown database') === false && strpos($msg, "doesn't exist") === false) { throw $e; } } }
/** * Loads the Erfurt configuration with an optional given config * object injected. * * @param Zend_Config|null $config */ public function loadConfig(Zend_Config $config = null) { // Load the default erfurt config. require_once 'Zend/Config/Ini.php'; if (is_readable(EF_BASE . 'config/default.ini')) { try { $this->_config = new Zend_Config_Ini(EF_BASE . 'config/default.ini', 'default', true); } catch (Zend_Config_Exception $e) { require_once 'Erfurt/App/Exception.php'; throw new Erfurt_App_Exception('Error while parsing config file default.ini.'); } } else { require_once 'Erfurt/App/Exception.php'; throw new Erfurt_App_Exception('Config file default.ini not readable.'); } // Load user config iff available. if (is_readable(EF_BASE . 'config.ini')) { try { $this->_config->merge(new Zend_Config_Ini(EF_BASE . 'config.ini', 'private', true)); } catch (Zend_Config_Exception $e) { require_once 'Erfurt/App/Exception.php'; throw new Erfurt_App_Exception('Error while parsing config file config.ini.'); } } // merge with injected config if given if (null !== $config) { try { $this->_config->merge($config); } catch (Zend_Config_Exception $e) { require_once 'Erfurt/App/Exception.php'; throw new Erfurt_App_Exception('Error while merging with injected config.'); } } }
/** * Constructor. * @param array $options */ public function __construct(Zend_Config $config = null) { $defaultConfig = new Zend_Config(array('style' => array('itemClass' => 'Item', 'titleClass' => 'Title', 'descriptionClass' => 'Description', 'tagContainerClass' => 'TagList', 'tagClass' => 'Tag', 'iconClass' => 'Icon', 'iconWidth' => 16, 'iconHeight' => 16, 'dateClass' => 'Date')), true); if (!is_null($config)) { $defaultConfig->merge($config); } $this->_config = $defaultConfig; }
/** * Get options * * @param array $options * @return void */ protected function _mergeOptions(array $options) { if (!isset($this->_options)) { $this->_options = new Zend_Config(array(), true); } $optionsConf = new Zend_Config($options, true); $this->_options->merge($optionsConf); }
/** * Pseudo-constructor (the actual constructor must be final). * @param Zend_Config $config * @return void */ protected function _init(Zend_Config $config) { $defaultConfig = new Zend_Config(array('url' => null, 'cacheLifetime' => 7200, 'cacheDir' => './cache', 'limit' => 5, 'items' => array()), true); if (!isset($config->url)) { throw new Polycast_Stalker_Provider_Exception('No feed url given'); } $this->_config = $defaultConfig->merge($config); }
public function loadFromMultiFiles(array $files, $ns, $save = true) { $conf = new Zend_Config(array(), true); foreach ($files as $file) { $fileConf = $this->_loadConfigFromFile($file); $conf->merge($fileConf); } return $this->processConfigFile($conf, $ns, $save); }
/** * Constructor. * @param Zend_Config $config */ public function __construct(Zend_Config $config = null) { $defaultConfig = new Zend_Config(array('providers' => array(), 'style' => array('id' => 'Stalker', 'class' => 'Stalker')), true); $defaultConfig->merge($config); $this->_config = $defaultConfig; foreach ($this->_config->providers as $name => $providerConfig) { $this->addProvider(Polycast_Stalker_Provider::factory($providerConfig), $name); } }
/** * Add configuration to the Fizzy application. The config is merged with * the already present config. Configuration can only be added before the * bootstrap sequence. * @param array|string|Zend_Config $config * @return Fizzy */ public function addConfig($config) { if (null !== $config) { if (is_array($config)) { $customConfig = new Zend_Config($config); } else { if ($config instanceof Zend_Config) { $customConfig = $config; } else { if (is_string($config)) { $customConfig = $this->_loadConfigFromFile($config); } } } # Merge configs $this->_config->merge($customConfig); } return $this; }
/** * @param array|\Zend_Config $config * @throws \Exception */ public static function mergeIntoConfig($config) { if (is_array($config)) { $config = new \Zend_Config($config); } elseif (!$config instanceof \Zend_Config) { throw new \Exception('no config given.'); } $curConfig = Registry::getConfig(); $newConfig = new \Zend_Config($curConfig->toArray(), true); $newConfig->merge($config); $newConfig->setReadOnly(); Registry::setConfig($newConfig); }
protected function _testConfig(array $config, &$error) { $outputConfig = new Zend_Config(array(), true); $outputConfig->merge(XenForo_Application::getInstance()->loadDefaultConfig())->merge(new Zend_Config($config)); try { $db = Zend_Db::factory($outputConfig->db->adapter, array('host' => $outputConfig->db->host, 'port' => $outputConfig->db->port, 'username' => $outputConfig->db->username, 'password' => $outputConfig->db->password, 'dbname' => $outputConfig->db->dbname, 'charset' => 'utf8')); $db->getConnection(); $db->listTables(); $error = ''; } catch (Zend_Db_Exception $e) { $error = new XenForo_Phrase('following_error_occurred_while_connecting_database', array('error' => $e->getMessage())); } return $db; }
public function _initConfig() { $config = new Zend_Config($this->getOptions(), true); $inifiles = array('app', 'cache', 'private'); //TODO: only load cache.ini for models foreach ($inifiles as $file) { $inifile = APPLICATION_PATH . "/configs/{$file}.ini"; if (is_readable($inifile)) { $config->merge(new Zend_Config_Ini($inifile)); } } $config->setReadOnly(); $this->setOptions($config->toArray()); Zend_Registry::set('config', $config); define('DATE_DB', 'Y-m-d H:i:s'); }
/** * Load both config files. * * @return Zend_Config */ public function init() { $mainConfig = $this->_coreResource->init(); $testConfigPath = APP_DIR . '/tests/config.ini'; $config = new Zend_Config_Ini($testConfigPath); if (!Zend_Registry::isRegistered('test_config')) { Zend_Registry::set('test_config', $config->testing); } // Merging the configs allows us to override settings only for tests. if ($config->site instanceof Zend_Config) { $mainCopy = new Zend_Config($mainConfig->toArray(), true); $mainCopy->merge($config->site); $mainCopy->setReadOnly(true); $mainConfig = $mainCopy; } return $mainConfig; }
/** * Sets the default route according to the configuration data provided in $config. * Two settings are required: the route prefix (key: routePrefix), * and the controller class-name (key: controllerClass). * * Three optional settings are supported as well: major section (key: majorSection), * minor section (key: minorSection) and request parameters (key: params); * which might be used during the routing process. * * @param Zend_Config $config Configuration data * @param array $dependencyData Data array supplied by the "init_dependencies" event * @throws XenForo_Exception */ public static function setDefaultRoute(Zend_Config $config, array $dependencyData) { $routesPublic = $dependencyData['routesPublic']; if (!$config->routePrefix || !$config->controllerClass) { // Debugging message. No need for phrasing. throw new XenForo_Exception('Missing route-prefix and/or controller class-name.'); } if ($config->readOnly()) { // A read-only object was passed. Arghh! $newConfig = new Zend_Config(array('routeClass' => $routesPublic[$config->routePrefix]['route_class']), true); $config = $newConfig->merge($config); } else { $config->routeClass = $routesPublic[$config->routePrefix]['route_class']; } self::_setCustomRoutePrefixes($config->routePrefix, $routesPublic); $config->setReadOnly(); XenForo_Application::set('customIndex', $config); }
/** * Initializes the Akrabat functionality and adds it to Zend_Tool (zf) * * @param string $env Environment to initialize for * * @return null * * @throws Zend_Tool_Project_Exception */ protected function _init($env) { $profile = $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION); $appConfigFileResource = $profile->search('applicationConfigFile'); if ($appConfigFileResource == false) { throw new Zend_Tool_Project_Exception('A project with an application config file is required to use this provider.'); } $appConfigFilePath = $appConfigFileResource->getPath(); // Base config, normally the application.ini in the configs dir of your app $this->_config = $this->_createConfig($appConfigFilePath, $env, true); // Are there any override config files? foreach ($this->_getAppConfigOverridePathList($appConfigFilePath) as $path) { $overrideConfig = $this->_createConfig($path); if (isset($overrideConfig->{$env})) { $this->_config->merge($overrideConfig->{$env}); } } require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->registerNamespace('Akrabat_'); }
/** * Creates the template configuration by merging the provided config files. * * @param array(string) $files * @return Zend_Config */ protected function getConfig(array $files) { $templates = new Zend_Config(array(), true); foreach ($files as $file) { /* @var $file string */ $config = new Zend_Config_Ini($file); $templates->merge($config); } return $templates; }
/** * Load the configuration file. Mixes in over top of the default values. Provided * a default is specified in {@link loadDefaultConfig}, all elements available * to the config will always be defined. Non-default elements may still be defined * in the loaded configuration. * * @return Zend_Config */ public function loadConfig() { if (file_exists($this->_configDir . '/config.php')) { $defaultConfig = $this->loadDefaultConfig(); $config = array(); require $this->_configDir . '/config.php'; $outputConfig = new Zend_Config(array(), true); $outputConfig->merge($defaultConfig)->merge(new Zend_Config($config))->setReadOnly(); return $outputConfig; } else { if (XenForo_Model::create('XenForo_Install_Model_Install')->isInstalled()) { // TODO: ideally, we want a better way to display a fatal error like this echo "Couldn't load library/config.php file."; exit; } else { header('Location: install/index.php'); exit; } } }
private static function loadConfigFiles($configFiles) { require_once 'Zend/Config/Ini.php'; $mergedConfig = new Zend_Config(array(), true); foreach ($configFiles as $configFile) { $config = new Zend_Config_Ini($configFile); $mergedConfig->merge($config); } return $mergedConfig; }
/** * _makeOptions * * @return array */ private function _makeOptions() { // Creates an empty configuration $options = new Zend_Config(array(), true); // Load default Config $options->merge($this->_getDefaultOptions()); // Load application Config $options->merge($this->_getAppOptions()); // Load forced Config $options->merge($this->_getForcedOptions()); return $options->toarray(); }
public function testMerge() { $stdArray = array('test_feature' => false, 'some_files' => array('foo' => 'dir/foo.xml', 'bar' => 'dir/bar.xml'), 2 => 123); $stdConfig = new Zend_Config($stdArray, true); $devArray = array('test_feature' => true, 'some_files' => array('bar' => 'myDir/bar.xml', 'baz' => 'myDir/baz.xml'), 2 => 456); $devConfig = new Zend_Config($devArray); $stdConfig->merge($devConfig); $this->assertTrue($stdConfig->test_feature); $this->assertEquals('myDir/bar.xml', $stdConfig->some_files->bar); $this->assertEquals('myDir/baz.xml', $stdConfig->some_files->baz); $this->assertEquals('dir/foo.xml', $stdConfig->some_files->foo); $this->assertEquals(456, $stdConfig->{2}); }
/** * Setup a database connection and store the adapter in the registry. * * @return void * * TODO put into configuration file (custom DB adapter) */ protected function _initDatabase() { $this->bootstrap(array('ZendCache', 'Logging', 'Configuration')); $logger = $this->getResource('Logging'); $logger->debug('Initializing database.'); // use custom DB adapter $config = new Zend_Config(array('db' => array('adapter' => 'Pdo_Mysqlutf8', 'params' => array('adapterNamespace' => 'Opus_Db_Adapter'))), true); // Include the above made configuration changes in the application configuration. $config->merge(Zend_Registry::get('Zend_Config')); // Put manipulated database configuration back to registry. Zend_Registry::set('Zend_Config', $config); // Use zend_Db factory to create a database adapter // and make it the default for all tables. $db = null; try { $db = Zend_Db::factory($config->db); Zend_Db_Table::setDefaultAdapter($db); // Register the adapter within Zend_Registry. Zend_Registry::set('db_adapter', $db); } catch (Zend_Db_Adapter_Exception $e) { $logger->err($e); throw new Exception('OPUS Bootstrap Error: Could not connect to database.'); } }
/** * @group ZF-3575 * */ public function testMergeHonoursAllowModificationsFlagAtAllLevels() { $config = new Zend_Config(array('key' => array('nested' => 'yes'), 'key2' => 'yes'), false); $config2 = new Zend_Config(array(), true); $config2->merge($config); try { $config2->key2 = 'no'; } catch (Zend_Config_Exception $e) { $this->fail('Unexpected exception at top level has been raised: ' . $e->getMessage()); } $this->assertEquals('no', $config2->key2); try { $config2->key->nested = 'no'; } catch (Zend_Config_Exception $e) { $this->fail('Unexpected exception on nested object has been raised: ' . $e->getMessage()); } $this->assertEquals('no', $config2->key->nested); }
/** * write config to a file * * @param array $_data * @param boolean $_merge * @param string $_filename * @return Zend_Config */ public function writeConfigToFile($_data, $_merge, $_filename) { // merge config data and active config if ($_merge) { $activeConfig = Setup_Core::get(Setup_Core::CONFIG); $config = new Zend_Config($activeConfig->toArray(), true); $config->merge(new Zend_Config($_data)); } else { $config = new Zend_Config($_data); } // write to file Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Updating config.inc.php'); $writer = new Zend_Config_Writer_Array(array('config' => $config, 'filename' => $_filename)); $writer->write(); return $config; }
/** * Loads custom parameters from a config file * * @access protected * @return void */ protected function _initParams() { // Load global parameters $config = new Zend_Config(array(), true); foreach (glob(CONFIG_FOLDER . "*.ini") as $configFile) { $config->merge(new Zend_Config_Ini($configFile, APPLICATION_ENV)); } Zend_Registry::set('params', $config); }
/** * import from egw14 * * @param Zend_Console_Getopt $_opts */ protected function _egw14Import(Zend_Console_Getopt $_opts) { $args = $_opts->getRemainingArgs(); if (count($args) < 1 || !is_readable($args[0])) { echo "can not open config file \n"; echo "see tine20.org/wiki/EGW_Migration_Howto for details \n\n"; echo "usage: ./setup.php --egw14import /path/to/config.ini (see Tinebase/Setup/Import/Egw14/config.ini)\n\n"; exit(1); } try { $config = new Zend_Config(array(), TRUE); $config->merge(new Zend_Config_Ini($args[0])); $config = $config->merge($config->all); } catch (Zend_Config_Exception $e) { fwrite(STDERR, "Error while parsing config file({$args['0']}) " . $e->getMessage() . PHP_EOL); exit(1); } $writer = new Zend_Log_Writer_Stream('php://output'); $logger = new Zend_Log($writer); $filter = new Zend_Log_Filter_Priority((int) $config->loglevel); $logger->addFilter($filter); $importer = new Tinebase_Setup_Import_Egw14($config, $logger); $importer->import(); }
/** * TODO: move to external class / trait * @return Zend_Config */ public function getGridConfig() { $config = new Zend_Config(array(), true); if (Zend_Registry::isRegistered('config') && isset(Zend_Registry::get('config')->dataGrid)) { $config->merge(Zend_Registry::get('config')->dataGrid); } $config->merge(new Zend_Config($this->_settings)); foreach ($config as $optionName => $optionValue) { if (!isset($optionValue->title) && isset($optionValue->label)) { $config->{$optionName}->title = $optionValue->label; unset($config->{$optionName}->label); } if (isset($optionValue->visible) && !$optionValue->visible) { $config->{$optionName}->hidden = true; } if (isset($optionValue->type)) { if (!isset($config->{$optionName}->jqg)) { $config->{$optionName}->jqg = new Zend_Config(array(), true); } switch ($optionValue->type) { case "select": $multiOptions = array(); $multiOptions[''] = 'LABEL_ALL'; $multiOptions += $config->{$optionName}->multiOptions->toArray(); $multiOptions = array_map(function ($key, $row) { $translate = App_Translate::getInstance(); return $key . ':' . $translate->translate($row); }, array_keys($multiOptions), $multiOptions); ksort($multiOptions); $multiOptions = implode(';', $multiOptions); $config->{$optionName}->jqg->merge(new Zend_Config(array('stype' => 'select', 'searchoptions' => array('sopt' => array('eq'), 'value' => $multiOptions), 'searchType' => '=')), true); break; case "date": $config->{$optionName}->merge(new Zend_Config(array('sorttype' => 'date', 'format' => array('date', array('date_format' => Zend_Date::DATE_MEDIUM)), 'jqg' => array('searchoptions' => array('dataInit' => new Zend_Json_Expr('function(el){ jQuery(el).datepicker({ dateFormat: "yy-mm-dd", onSelect: function(dateText, inst){ jQuery(el).parents(".ui-jqgrid").find(".ui-jqgrid-btable").get(0).triggerToolbar(); } }); }'))))), true); if (!isset($config->{$optionName}->defaultvalue)) { $config->{$optionName}->defaultvalue = null; } break; case "datetime": $config->{$optionName}->merge(new Zend_Config(array('sorttype' => 'date', 'format' => array('date', array('date_format' => Zend_Date::DATETIME_SHORT)), 'jqg' => array('searchoptions' => array('dataInit' => new Zend_Json_Expr('function(el){ jQuery(el).datetimepicker({ dateFormat: "yy-mm-dd", timeFormat: "hh:mm", onSelect: function(dateText, inst){ jQuery(el).parents(".ui-jqgrid").find(".ui-jqgrid-btable").get(0).triggerToolbar(); } }); }'))))), true); if (!isset($config->{$optionName}->defaultvalue)) { $config->{$optionName}->defaultvalue = null; } break; case "time": $config->{$optionName}->merge(new Zend_Config(array('sorttype' => 'date', 'format' => array('date', array('date_format' => Zend_Date::TIME_SHORT)), 'jqg' => array('searchoptions' => array('dataInit' => new Zend_Json_Expr('function(el){ jQuery(el).timepicker({ timeFormat: "hh:mm", onSelect: function(dateText, inst){ jQuery(el).parents(".ui-jqgrid").find(".ui-jqgrid-btable").get(0).triggerToolbar(); } }); }'))))), true); if (!isset($config->{$optionName}->defaultvalue)) { $config->{$optionName}->defaultvalue = null; } break; case "boolean": case "bool": $multiOptions = array('' => 'LABEL_ALL', '0' => 'LABEL_NO', '1' => 'LABEL_YES'); $multiOptions = array_map(function ($key, $row) { $translate = App_Translate::getInstance(); return $key . ':' . $translate->translate($row); }, array_keys($multiOptions), $multiOptions); $multiOptions = implode(';', $multiOptions); $config->{$optionName}->merge(new Zend_Config(array('width' => 30, 'align' => 'center', 'jqg' => array('stype' => 'select', 'searchoptions' => array('sopt' => array('eq'), 'value' => $multiOptions)), 'searchType' => '=')), true); if (!isset($config->{$optionName}->helper) && !isset($config->{$optionName}->callback)) { $config->{$optionName}->merge(new Zend_Config(array('jqg' => array('formatter' => 'checkbox'))), true); } break; case "int": $config->{$optionName}->merge(new Zend_Config(array('searchType' => '=')), true); break; default: debug_assert(false !== array_search($optionValue->type, self::$types), "Unknown Grid Cell Type `{$optionValue->type}`"); } } } return $config; }
public function testPublistActionWithValidStylesheetInConfig() { // manipulate application configuration $oldConfig = Zend_Registry::get('Zend_Config'); $config = Zend_Registry::get('Zend_Config'); if (isset($config->plugins->export->publist->stylesheet)) { $config->plugins->export->publist->stylesheet = 'raw'; } else { $config = new Zend_Config(array('plugins' => array('export' => array('publist' => array('stylesheet' => 'raw')), true))); // Include the above made configuration changes in the application configuration. $config->merge(Zend_Registry::get('Zend_Config')); } if (isset($config->plugins->export->publist->stylesheetDirectory)) { $config->plugins->export->publist->stylesheetDirectory = 'stylesheets'; } else { $config = new Zend_Config(array('plugins' => array('export' => array('publist' => array('stylesheetDirectory' => 'stylesheets')), true))); // Include the above made configuration changes in the application configuration. $config->merge(Zend_Registry::get('Zend_Config')); } Zend_Registry::set('Zend_Config', $config); $this->dispatch('/export/index/publist/role/publists/number/coll_visible'); // undo configuration manipulation Zend_Registry::set('Zend_Config', $oldConfig); $this->assertResponseCode(200); $response = $this->getResponse(); $this->assertContains('<export timestamp=', $response->getBody()); $this->assertContains('</export>', $response->getBody()); }
/** * load configs for an extension * - respect local ini's * - fix missing or dirty values * * @param $name string containing the name of an extension * * @return Zend_Config */ private function _loadConfigs($name) { $path = $this->_extensionPath . $name . DIRECTORY_SEPARATOR; $config = new Zend_Config(self::loadDoapN3($path . self::EXTENSION_DEFAULT_DOAP_FILE, $name), true); // overwrites default config with local config $localConfigPath = $this->_extensionPath . $name . '.ini'; if (is_readable($localConfigPath)) { //the local config is still in ini syntax $localConfig = new Zend_Config_Ini($localConfigPath, null, true); $config->merge($localConfig); } //fix missing names if (!isset($config->name)) { $config->name = $name; } //fix deprecated/invalid values for "enabled" if (is_string($config->enabled)) { switch ($config->enabled) { case '1': case 'enabled': case 'true': case 'on': case 'yes': $config->enabled = true; break; default: $config->enabled = false; } } // normalize paths foreach ($this->_pathKeys as $pathKey) { if (isset($config->{$pathKey})) { $config->{$pathKey} = rtrim($config->{$pathKey}, '/\\') . '/'; } } // save component's path $config->path = $path; return $config; }
private function setAsyncIndexmaintenanceMode($value) { $config = Zend_Registry::get('Zend_Config'); if (isset($config->runjobs->indexmaintenance->asynchronous)) { $config->runjobs->indexmaintenance->asynchronous = $value; } else { $config = new Zend_Config(array('runjobs' => array('indexmaintenance' => array('asynchronous' => $value))), true); $config->merge(Zend_Registry::get('Zend_Config')); } Zend_Registry::set('Zend_Config', $config); }
} if (isset($arr['zend']['zend_path'])) { $zenddir = $arr['zend']['zend_path']; } } // Setup include path //add zend directory to include path set_include_path(get_include_path() . PATH_SEPARATOR . $zenddir); // Initialize Zend Framework loader require_once 'Zend/Loader/Autoloader.php'; // require_once 'services/Pdoconfig.php'; // require_once 'services/UserModel.php'; Zend_Loader_Autoloader::getInstance(); // Load configuration $default_config = new Zend_Config(array("production" => false), true); $default_config->merge(new Zend_Config_Ini($configfile, 'zendamf')); $default_config->setReadOnly(); $amf = $default_config->amf; // Store configuration in the registry Zend_Registry::set("amf-config", $amf); // Initialize AMF Server $server = new Zend_Amf_Server(); $server->setProduction($amf->production); if (isset($amf->directories)) { $dirs = $amf->directories->toArray(); foreach ($dirs as $dir) { // get the first character of the path. // If it does not start with slash then it implies that the path is relative to webroot. Else it will be treated as absolute path $length = strlen($dir); $firstChar = $dir; if ($length >= 1) {