rendered paste bodyconfig_handlers.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configurations parent="%core.system_config_dir%/config_handlers.xml">
<configuration>
<handlers>
<handler pattern="%core.config_dir%/facebook.xml" class="ConfigDirectivesConfigHandler" />
</handlers>
</configuration>
</configurations>
autoload.xml:
<autoload name="ConfigDirectivesConfigHandler">%core.lib_dir%/ConfigDirectivesConfigHandler.class.php</autoload>
<?php
/**
*
* @author Veikko Makinen <mail@veikkomakinen.com
* @copyright (c) Authors
*
* @version $Id$
*/
class ConfigDirectivesConfigHandler extends AgaviConfigHandler
{
/**
* @see AgaviIniConfigHandler::execute()
*
*/
public function execute($config, $context = null)
{
$configurations = $this->orderConfigurations(AgaviConfigCache::parseConfig($config, false, $this->getValidationFile())->configurations, AgaviConfig::get('core.environment'), $context);
$code = '';
foreach($configurations as $cfg) {
$code .= $this->convert($cfg);
}
date_default_timezone_set('GMT');
// compile data
$retval = "<?php\n" .
"// auto-generated by ".__CLASS__."\n" .
"// date: %s\n%s\n?>";
$retval = sprintf($retval, date('m/d/Y H:i:s'), $code);
return $retval;
}
/**
*
* @param AgaviConfigValueHolder The config value to convert.
*
* @author Veikko Makinen <mail@veikkomakinen.com>
*/
protected function convert(AgaviConfigValueHolder $item)
{
$prefix = '';
$data = '';
foreach($item->getChildren() as $directives) {
$prefix = $directives->getAttribute('prefix', '');
foreach($directives->getChildren() as $directive) {
$name = ($prefix ? $prefix.'.' : '') . $directive->getAttribute('name');
$value = var_export($this->literalize($this->replaceConstants($directive->getValue())), true);
$data .= "AgaviConfig::set('$name', $value); \n";
}
}
return $data;
}
}
?>