/**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     David Zülke <*****@*****.**>
  * @since      0.9.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'suite');
     // remember the config file path
     $config = $document->documentURI;
     $data = array();
     // loop over <configuration> elements
     foreach ($document->getConfigurationElements() as $configuration) {
         foreach ($configuration->get('suites') as $current) {
             $includes = array();
             foreach ($current->get('includes') as $include) {
                 $includes[] = $include->textContent;
             }
             $excludes = array();
             foreach ($current->get('excludes') as $exclude) {
                 $excludes[] = $exclude->textContent;
             }
             $suite = array('class' => $current->getAttribute('class', 'AgaviTestSuite'), 'base' => $current->getAttribute('base', 'tests/'), 'includes' => $includes, 'excludes' => $excludes);
             $suite['testfiles'] = array();
             foreach ($current->get('testfiles') as $file) {
                 $suite['testfiles'][] = $file->textContent;
             }
             $data[$current->getAttribute('name')] = $suite;
         }
     }
     $code = 'return ' . var_export($data, true);
     return $this->generate($code, $config);
 }
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     $data = array();
     $prefix = "org.icinga.";
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'settings');
     foreach ($document->getConfigurationElements() as $cfg) {
         foreach ($cfg->get('settings') as $setting) {
             $localPrefix = $prefix;
             // let's see if this buddy has a <settings> parent with valuable information
             if ($setting->parentNode->localName == 'settings') {
                 if ($setting->parentNode->hasAttribute('prefix')) {
                     $localPrefix = $setting->parentNode->getAttribute('prefix');
                 }
             }
             $settingName = $localPrefix . $setting->getAttribute('name');
             if ($setting->hasAgaviParameters()) {
                 $data[$settingName] = $setting->getAgaviParameters();
             } else {
                 $data[$settingName] = AgaviToolkit::literalize($setting->getValue());
             }
         }
     }
     $code = 'AgaviConfig::fromArray(' . var_export($data, true) . ');';
     return $this->generate($code, $document->documentURI);
 }
 /**
  * Execute this configuration handler.
  *
  * @param      string An absolute filesystem path to a configuration file.
  * @param      string An optional context in which we are currently running.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviUnreadableException</b> If a requested configuration
  *                                             file does not exist or is not
  *                                             readable.
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Uwe Mesecke <*****@*****.**>
  * @author     Dominik del Bondio <*****@*****.**>
  * @since      0.11.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'validators');
     $config = $document->documentURI;
     $classMap = array();
     $code = array();
     //array('lines' => array(), 'order' => array());
     foreach ($document->getConfigurationElements() as $cfg) {
         if ($cfg->has('validator_definitions')) {
             foreach ($cfg->get('validator_definitions') as $def) {
                 $name = $def->getAttribute('name');
                 if (!isset($this->classMap[$name])) {
                     $this->classMap[$name] = array('class' => $def->getAttribute('class'), 'parameters' => array());
                 }
                 $this->classMap[$name]['class'] = $def->getAttribute('class', $this->classMap[$name]['class']);
                 $this->classMap[$name]['parameters'] = $def->getAgaviParameters($this->classMap[$name]['parameters']);
             }
         }
         $code = $this->processValidatorElements($cfg, $code, 'validationManager');
     }
     $newCode = array();
     if (isset($code[''])) {
         $newCode = $code[''];
         unset($code['']);
     }
     foreach ($code as $method => $codes) {
         $newCode[] = 'if($method == ' . var_export($method, true) . ') {';
         foreach ($codes as $line) {
             $newCode[] = $line;
         }
         $newCode[] = '}';
     }
     return $this->generate($newCode, $config);
 }
 /**
  * Creates an XI element with file and Xpointer syntax
  * @param AgaviXmlConfigDomDocument $document
  * @param string                    $file
  * @param string                    $pointer    Whole Xpointer syntax with ns and query
  */
 public static function createXIncludeNode(AgaviXmlConfigDomDocument $document, $file, $pointer)
 {
     $element = $document->createElementNS('http://www.w3.org/2001/XInclude', 'xi:include');
     $element->setAttribute('href', $file);
     $element->setAttribute('xpointer', $pointer);
     return $element;
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Sean Kerr <*****@*****.**>
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     David Zülke <*****@*****.**>
  * @since      0.9.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'compile');
     $config = $document->documentURI;
     $data = array();
     // let's do our fancy work
     foreach ($document->getConfigurationElements() as $configuration) {
         if (!$configuration->has('compiles')) {
             continue;
         }
         foreach ($configuration->get('compiles') as $compileFile) {
             $file = trim($compileFile->getValue());
             $file = AgaviToolkit::expandDirectives($file);
             $file = self::replacePath($file);
             $file = realpath($file);
             if (!is_readable($file)) {
                 // file doesn't exist
                 $error = 'Configuration file "%s" specifies nonexistent ' . 'or unreadable file "%s"';
                 $error = sprintf($error, $config, $compileFile->getValue());
                 throw new AgaviParseException($error);
             }
             if (AgaviConfig::get('core.debug', false)) {
                 // debug mode, just require() the files, makes for nicer stack traces
                 $contents = 'require(' . var_export($file, true) . ');';
             } else {
                 // no debug mode, so make things fast
                 $contents = $this->formatFile(file_get_contents($file));
             }
             // append file data
             $data[$file] = $contents;
         }
     }
     return $this->generate($data, $config);
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Sean Kerr <*****@*****.**>
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     Noah Fontes <*****@*****.**>
  * @since      0.9.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'databases');
     $databases = array();
     $default = null;
     foreach ($document->getConfigurationElements() as $configuration) {
         if (!$configuration->hasChildren('databases')) {
             continue;
         }
         $databasesElement = $configuration->getChild('databases');
         // make sure we have a default database exists
         if (!$databasesElement->hasAttribute('default') && $default === null) {
             // missing default database
             $error = 'Configuration file "%s" must specify a default database configuration';
             $error = sprintf($error, $document->documentURI);
             throw new AgaviParseException($error);
         }
         if ($databasesElement->hasAttribute('default')) {
             $default = $databasesElement->getAttribute('default');
         }
         // let's do our fancy work
         foreach ($configuration->get('databases') as $database) {
             $name = $database->getAttribute('name');
             if (!isset($databases[$name])) {
                 $databases[$name] = array('parameters' => array());
                 if (!$database->hasAttribute('class')) {
                     $error = 'Configuration file "%s" specifies database "%s" with missing class key';
                     $error = sprintf($error, $document->documentURI, $name);
                     throw new AgaviParseException($error);
                 }
             }
             $databases[$name]['class'] = $database->hasAttribute('class') ? $database->getAttribute('class') : $databases[$name]['class'];
             $databases[$name]['parameters'] = $database->getAgaviParameters($databases[$name]['parameters']);
         }
     }
     if (!$databases) {
         // we have no connections
         $error = 'Configuration file "%s" does not contain any database connections.';
         $error = sprintf($error, $document->documentURI);
         throw new AgaviConfigurationException($error);
     }
     $data = array();
     foreach ($databases as $name => $db) {
         // append new data
         $data[] = sprintf('$database = new %s();', $db['class']);
         $data[] = sprintf('$this->databases[%s] = $database;', var_export($name, true));
         $data[] = sprintf('$database->initialize($this, %s);', var_export($db['parameters'], true));
     }
     if (!isset($databases[$default])) {
         $error = 'Configuration file "%s" specifies undefined default database "%s".';
         $error = sprintf($error, $document->documentURI, $default);
         throw new AgaviConfigurationException($error);
     }
     $data[] = sprintf('$this->defaultDatabaseName = %s;', var_export($default, true));
     return $this->generate($data, $document->documentURI);
 }
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     $this->document = $document;
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'ic');
     $this->setupXPath();
     $this->fetchParameters();
     $commands = $this->fetchCommands();
     return $this->generate('return ' . var_export($commands, true));
 }
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     $this->document = $document;
     $this->menuDefinition = new AppKitLinkedList();
     $this->context = AgaviContext::getInstance();
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'm');
     $this->setupXPath();
     $this->fetchMenudefinition();
     return $this->generate('return ' . var_export($this->menuDefinition->toArray(), true));
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @author     David Zülke <*****@*****.**>
  * @since      0.11.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     $document->setDefaultNamespace($this->getParameter('namespace_uri', ''));
     $data = array();
     foreach ($document->getConfigurationElements() as $cfg) {
         $data = array_merge($data, $this->convertToArray($cfg, true));
     }
     // compile data
     $code = 'return ' . var_export($data, true) . ';';
     return $this->generate($code, $document->documentURI);
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     David Zülke <*****@*****.**>
  * @since      0.11.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'translation');
     $config = $document->documentURI;
     $translatorData = array();
     $localeData = array();
     $defaultDomain = '';
     $defaultLocale = null;
     $defaultTimeZone = null;
     foreach ($document->getConfigurationElements() as $cfg) {
         if ($cfg->hasChild('available_locales')) {
             $availableLocales = $cfg->getChild('available_locales');
             // TODO: is this really optional? according to the schema: yes...
             $defaultLocale = $availableLocales->getAttribute('default_locale', $defaultLocale);
             $defaultTimeZone = $availableLocales->getAttribute('default_timezone', $defaultTimeZone);
             foreach ($availableLocales as $locale) {
                 $name = $locale->getAttribute('identifier');
                 if (!isset($localeData[$name])) {
                     $localeData[$name] = array('name' => $name, 'params' => array(), 'fallback' => null, 'ldml_file' => null);
                 }
                 $localeData[$name]['params'] = $locale->getAgaviParameters($localeData[$name]['params']);
                 $localeData[$name]['fallback'] = $locale->getAttribute('fallback', $localeData[$name]['fallback']);
                 $localeData[$name]['ldml_file'] = $locale->getAttribute('ldml_file', $localeData[$name]['ldml_file']);
             }
         }
         if ($cfg->hasChild('translators')) {
             $translators = $cfg->getChild('translators');
             $defaultDomain = $translators->getAttribute('default_domain', $defaultDomain);
             $this->getTranslators($translators, $translatorData);
         }
     }
     $data = array();
     $data[] = sprintf('$this->defaultDomain = %s;', var_export($defaultDomain, true));
     $data[] = sprintf('$this->defaultLocaleIdentifier = %s;', var_export($defaultLocale, true));
     $data[] = sprintf('$this->defaultTimeZone = %s;', var_export($defaultTimeZone, true));
     foreach ($localeData as $locale) {
         // TODO: fallback stuff
         $data[] = sprintf('$this->availableConfigLocales[%s] = array(\'identifier\' => %s, \'identifierData\' => %s, \'parameters\' => %s);', var_export($locale['name'], true), var_export($locale['name'], true), var_export(AgaviLocale::parseLocaleIdentifier($locale['name']), true), var_export($locale['params'], true));
     }
     foreach ($translatorData as $domain => $translator) {
         foreach (array('msg', 'num', 'cur', 'date') as $type) {
             if (isset($translator[$type]['class'])) {
                 if (!class_exists($translator[$type]['class'])) {
                     throw new AgaviConfigurationException(sprintf('The Translator or Formatter class "%s" for domain "%s" could not be found.', $translator[$type]['class'], $domain));
                 }
                 $data[] = join("\n", array(sprintf('$this->translators[%s][%s] = new %s();', var_export($domain, true), var_export($type, true), $translator[$type]['class']), sprintf('$this->translators[%s][%s]->initialize($this->getContext(), %s);', var_export($domain, true), var_export($type, true), var_export($translator[$type]['params'], true)), sprintf('$this->translatorFilters[%s][%s] = %s;', var_export($domain, true), var_export($type, true), var_export($translator[$type]['filters'], true))));
             }
         }
     }
     return $this->generate($data, $config);
 }
 /**
  * Generates the processing chain.
  *
  * @author     Noah Fontes <*****@*****.**>
  * @since      1.0.0
  */
 protected static function createProcessors()
 {
     self::$processors = array();
     self::$processorCount = 0;
     foreach (self::$chain as $file) {
         $processorImpl = new AgaviXmlConfigDomDocument();
         $processorImpl->load(AgaviConfig::get('core.agavi_dir') . '/config/schematron/' . $file);
         $processor = new AgaviXmlConfigXsltProcessor();
         $processor->importStylesheet($processorImpl);
         self::$processors[] = $processor;
         self::$processorCount++;
     }
 }
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'cronk');
     $config = $document->documentURI;
     $cronks = array();
     $categories = array();
     foreach ($document->getConfigurationElements() as $cfg) {
         $this->getXmlConfiguration($cfg, 'cronks', 'cronk', $cronks);
         $this->getXmlConfiguration($cfg, 'categories', 'category', $categories);
     }
     $code = 'return ' . var_export(array($cronks, $categories), true);
     return $this->generate($code, $config);
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviUnreadableException</b> If a requested configuration
  *                                             file does not exist or is not
  *                                             readable.
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     David Zülke <*****@*****.**>
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     Sean Kerr <*****@*****.**>
  * @since      0.9.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'settings');
     // init our data array
     $data = array();
     $prefix = 'core.';
     foreach ($document->getConfigurationElements() as $cfg) {
         // let's do our fancy work
         if ($cfg->has('system_actions')) {
             foreach ($cfg->get('system_actions') as $action) {
                 $name = $action->getAttribute('name');
                 $data[sprintf('actions.%s_module', $name)] = $action->getChild('module')->getValue();
                 $data[sprintf('actions.%s_action', $name)] = $action->getChild('action')->getValue();
             }
         }
         // loop over <setting> elements; there can be many of them
         foreach ($cfg->get('settings') as $setting) {
             $localPrefix = $prefix;
             // let's see if this buddy has a <settings> parent with valuable information
             if ($setting->parentNode->localName == 'settings') {
                 if ($setting->parentNode->hasAttribute('prefix')) {
                     $localPrefix = $setting->parentNode->getAttribute('prefix');
                 }
             }
             $settingName = $localPrefix . $setting->getAttribute('name');
             if ($setting->hasAgaviParameters()) {
                 $data[$settingName] = $setting->getAgaviParameters();
             } else {
                 $data[$settingName] = $setting->getLiteralValue();
             }
         }
         if ($cfg->has('exception_templates')) {
             foreach ($cfg->get('exception_templates') as $exception_template) {
                 $tpl = AgaviToolkit::expandDirectives($exception_template->getValue());
                 if (!is_readable($tpl)) {
                     throw new AgaviConfigurationException('Exception template "' . $tpl . '" does not exist or is unreadable');
                 }
                 if ($exception_template->hasAttribute('context')) {
                     foreach (array_map('trim', explode(' ', $exception_template->getAttribute('context'))) as $ctx) {
                         $data['exception.templates.' . $ctx] = $tpl;
                     }
                 } else {
                     $data['exception.default_template'] = AgaviToolkit::expandDirectives($tpl);
                 }
             }
         }
     }
     $code = 'AgaviConfig::fromArray(' . var_export($data, true) . ');';
     return $this->generate($code, $document->documentURI);
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviUnreadableException</b> If a requested configuration
  *                                             file does not exist or is not
  *                                             readable.
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     David Zülke <*****@*****.**>
  * @since      0.11.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'rbac_definitions');
     $data = array();
     foreach ($document->getConfigurationElements() as $cfg) {
         if (!$cfg->has('roles')) {
             continue;
         }
         $this->parseRoles($cfg->get('roles'), null, $data);
     }
     $code = "return " . var_export($data, true) . ";";
     return $this->generate($code, $document->documentURI);
 }
 /**
  * Execute this configuration handler.
  *
  * @param      <b>AgaviXmlConfigDomDocument</b> The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviUnreadableException</b> If a requested configuration
  *                                             file does not exist or is not
  *                                             readable.
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Luis Merino <*****@*****.**>
  * @since      0.1.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // setting up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'static_files');
     $routing = $this->context->getRouting();
     $data = array();
     // let's do our fancy work
     foreach ($document->getConfigurationElements() as $cfg) {
         if ($cfg->has('routes')) {
             $this->parseRoutesAndFiles($routing, $cfg->get('routes'), $data);
         }
     }
     $code = sprintf('$this->files = %s;', var_export($data, true));
     return $this->generate($code, $document->documentURI);
 }
 /**
  * parent::execute would overwrite the routing default namespace with the one agavi uses, so we
  * cannot simply call the parent one (self::XML_NAMESPACE wouldn't refer to http://icinga.org/...)
  * This is just a copy of @See AgaviRoutingConfigHandler::execute and additionally calls the Ext.direct
  * Provider
  *
  * @param    AgaviXmlConfigDomDocument   The DOMDocument to parse
  *
  * @author   Jannis Moßhammer   <*****@*****.**>
  *
  **/
 private function parent_execute(AgaviXmlConfigDomDocument $document)
 {
     $routing = AgaviContext::getInstance($this->context)->getRouting();
     $this->unnamedRoutes = array();
     $routing->importRoutes(array());
     $data = array();
     foreach ($document->getConfigurationElements() as $cfg) {
         if ($cfg->has('routes')) {
             $this->parseRoutesExtended($routing, $cfg->get('routes'));
             $this->parseApiProviders();
             $this->parseRoutes($routing, $cfg->get('routes'), $parent = null);
         }
     }
     return serialize($routing->exportRoutes());
 }
 /**
  * (non-PHPdoc)
  * @see AgaviIXmlConfigHandler::execute()
  */
 public function execute(AgaviXmlConfigDomDocument $doc)
 {
     $resources = array_combine(array_keys($this->_resources), array_fill(0, count($this->_resources), array()));
     $jactions = array();
     foreach ($doc->getConfigurationElements() as $cfg) {
         // Collecting resources
         foreach ($this->_resources as $resource => $sfx) {
             $resources[$resource] = array_unique(array_merge($resources[$resource], $this->collectResource($resource, $sfx, $cfg)));
         }
         // Collecting javascript actions
         foreach ($cfg->getChildren('jactions', null, true) as $jaction) {
             $jactions[] = $jaction->getAgaviParameters();
         }
     }
     return $this->generate(sprintf('$this->resources = array_merge_recursive($this->resources, %s);%s$this->jactions=array_merge_recursive($this->jactions, %s);', var_export($resources, true), chr(10), var_export($jactions, true)), $doc->documentURI);
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     David Zülke <*****@*****.**>
  * @since      0.9.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'module');
     // remember the config file path
     $config = $document->documentURI;
     $enabled = false;
     $prefix = 'modules.${moduleName}.';
     $data = array();
     // loop over <configuration> elements
     foreach ($document->getConfigurationElements() as $configuration) {
         $module = $configuration->getChild('module');
         if (!$module) {
             continue;
         }
         // enabled flag is treated separately
         $enabled = (bool) AgaviToolkit::literalize($module->getAttribute('enabled'));
         // loop over <setting> elements; there can be many of them
         foreach ($module->get('settings') as $setting) {
             $localPrefix = $prefix;
             // let's see if this buddy has a <settings> parent with valuable information
             if ($setting->parentNode->localName == 'settings') {
                 if ($setting->parentNode->hasAttribute('prefix')) {
                     $localPrefix = $setting->parentNode->getAttribute('prefix');
                 }
             }
             $settingName = $localPrefix . $setting->getAttribute('name');
             if ($setting->hasAgaviParameters()) {
                 $data[$settingName] = $setting->getAgaviParameters();
             } else {
                 $data[$settingName] = AgaviToolkit::literalize($setting->getValue());
             }
         }
     }
     $code = array();
     $code[] = '$lcModuleName = strtolower($moduleName);';
     $code[] = 'AgaviConfig::set(AgaviToolkit::expandVariables(' . var_export($prefix . 'enabled', true) . ', array(\'moduleName\' => $lcModuleName)), ' . var_export($enabled, true) . ', true, true);';
     if (count($data)) {
         $code[] = '$moduleConfig = ' . var_export($data, true) . ';';
         $code[] = '$moduleConfigKeys = array_keys($moduleConfig);';
         $code[] = 'foreach($moduleConfigKeys as &$value) $value = AgaviToolkit::expandVariables($value, array(\'moduleName\' => $lcModuleName));';
         $code[] = '$moduleConfig = array_combine($moduleConfigKeys, $moduleConfig);';
         $code[] = 'AgaviConfig::fromArray($moduleConfig);';
     }
     return $this->generate($code, $config);
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to handle.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviUnreadableException</b> If a requested configuration
  *                                             file does not exist or is not
  *                                             readable.
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     Noah Fontes <*****@*****.**>
  * @author     David Zülke <*****@*****.**>
  * @since      0.11.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'config_handlers');
     // init our data arrays
     $handlers = array();
     foreach ($document->getConfigurationElements() as $configuration) {
         if (!$configuration->has('handlers')) {
             continue;
         }
         // let's do our fancy work
         foreach ($configuration->get('handlers') as $handler) {
             $pattern = $handler->getAttribute('pattern');
             $category = AgaviToolkit::normalizePath(AgaviToolkit::expandDirectives($pattern));
             $class = $handler->getAttribute('class');
             $transformations = array(AgaviXmlConfigParser::STAGE_SINGLE => array(), AgaviXmlConfigParser::STAGE_COMPILATION => array());
             if ($handler->has('transformations')) {
                 foreach ($handler->get('transformations') as $transformation) {
                     $path = AgaviToolkit::literalize($transformation->getValue());
                     $for = $transformation->getAttribute('for', AgaviXmlConfigParser::STAGE_SINGLE);
                     $transformations[$for][] = $path;
                 }
             }
             $validations = array(AgaviXmlConfigParser::STAGE_SINGLE => array(AgaviXmlConfigParser::STEP_TRANSFORMATIONS_BEFORE => array(AgaviXmlConfigParser::VALIDATION_TYPE_RELAXNG => array(), AgaviXmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(), AgaviXmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array()), AgaviXmlConfigParser::STEP_TRANSFORMATIONS_AFTER => array(AgaviXmlConfigParser::VALIDATION_TYPE_RELAXNG => array(), AgaviXmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(), AgaviXmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array())), AgaviXmlConfigParser::STAGE_COMPILATION => array(AgaviXmlConfigParser::STEP_TRANSFORMATIONS_BEFORE => array(AgaviXmlConfigParser::VALIDATION_TYPE_RELAXNG => array(), AgaviXmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(), AgaviXmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array()), AgaviXmlConfigParser::STEP_TRANSFORMATIONS_AFTER => array(AgaviXmlConfigParser::VALIDATION_TYPE_RELAXNG => array(), AgaviXmlConfigParser::VALIDATION_TYPE_SCHEMATRON => array(), AgaviXmlConfigParser::VALIDATION_TYPE_XMLSCHEMA => array())));
             if ($handler->has('validations')) {
                 foreach ($handler->get('validations') as $validation) {
                     $path = AgaviToolkit::literalize($validation->getValue());
                     $type = null;
                     if (!$validation->hasAttribute('type')) {
                         $type = $this->guessValidationType($path);
                     } else {
                         $type = $validation->getAttribute('type');
                     }
                     $for = $validation->getAttribute('for', AgaviXmlConfigParser::STAGE_SINGLE);
                     $step = $validation->getAttribute('step', AgaviXmlConfigParser::STEP_TRANSFORMATIONS_AFTER);
                     $validations[$for][$step][$type][] = $path;
                 }
             }
             $handlers[$category] = isset($handlers[$category]) ? $handlers[$category] : array('parameters' => array());
             $handlers[$category] = array('class' => $class, 'parameters' => $handler->getAgaviParameters($handlers[$category]['parameters']), 'transformations' => $transformations, 'validations' => $validations);
         }
     }
     $data = array('return ' . var_export($handlers, true));
     return $this->generate($data, $document->documentURI);
 }
 /**
  * Fetches the Validation xml for the action/module combination and returns it as
  * an DOMDocument
  *
  * @param    string  The module name
  * @param    string  The action to get the validation xml for
  * @return   AgaviXmlConfigDomDocument
  *
  * @author   Jannis Moßhammer<*****@*****.**>
  * @throws   AgaviConfigurationException     when module or action does not exist
  */
 protected function getValidatorXMLForAction($module, $action)
 {
     // get Module path
     $path = AgaviToolkit::literalize('%core.module_dir%') . "/" . $module;
     if (!file_exists(AgaviToolkit::normalizePath($path))) {
         throw new AgaviConfigurationException("Couldn't find module " . $module);
     }
     // get Validation file
     $actionPath = str_replace(".", "/", $action);
     $xml = $path . "/validate/" . $actionPath . ".xml";
     if (!file_exists(AgaviToolkit::normalizePath($path))) {
         throw new AgaviConfigurationException("Couldn't find validation file for " . $action);
     }
     $dom = new AgaviXmlConfigDomDocument();
     $dom->load(AgaviToolKit::normalizePath($xml));
     //TODO: Validate xml
     return $dom;
 }
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     $code = array();
     $parser = new CronkGridTemplateXmlParser();
     $parser->disableCache();
     $templates = $document->getElementsByTagName("template");
     foreach ($templates as $extension) {
         $attrs = $extension->attributes;
         $pattern = $attrs->getNamedItem('match-pattern');
         if (!$pattern) {
             continue;
         }
         // we don't have a dtd, so this can happen
         $parser->setDom($extension);
         $parser->parseTemplate(true);
         $code[] = array("pattern" => $pattern->value, "data" => $parser->getTemplateData(), "fields" => $parser->getFields());
     }
     return $this->generate('return ' . var_export($code, true));
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     David Zülke <*****@*****.**>
  * @author     Sean Kerr <*****@*****.**>
  * @since      0.9.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'filters');
     $config = $document->documentURI;
     $filters = array();
     foreach ($document->getConfigurationElements() as $cfg) {
         if ($cfg->has('filters')) {
             foreach ($cfg->get('filters') as $filter) {
                 $name = $filter->getAttribute('name', AgaviToolkit::uniqid());
                 if (!isset($filters[$name])) {
                     $filters[$name] = array('params' => array(), 'enabled' => AgaviToolkit::literalize($filter->getAttribute('enabled', true)));
                 } else {
                     $filters[$name]['enabled'] = AgaviToolkit::literalize($filter->getAttribute('enabled', $filters[$name]['enabled']));
                 }
                 if ($filter->hasAttribute('class')) {
                     $filters[$name]['class'] = $filter->getAttribute('class');
                 }
                 $filters[$name]['params'] = $filter->getAgaviParameters($filters[$name]['params']);
             }
         }
     }
     $data = array();
     foreach ($filters as $name => $filter) {
         if (stripos($name, 'agavi') === 0) {
             throw new AgaviConfigurationException('Filter names must not start with "agavi".');
         }
         if (!isset($filter['class'])) {
             throw new AgaviConfigurationException('No class name specified for filter "' . $name . '" in ' . $config);
         }
         if ($filter['enabled']) {
             $rc = new ReflectionClass($filter['class']);
             $if = 'AgaviI' . ucfirst(strtolower(substr(basename($config), 0, strpos(basename($config), '_filters')))) . 'Filter';
             if (!$rc->implementsInterface($if)) {
                 throw new AgaviFactoryException('Filter "' . $name . '" does not implement interface "' . $if . '"');
             }
             $data[] = '$filter = new ' . $filter['class'] . '();';
             $data[] = '$filter->initialize($this->context, ' . var_export($filter['params'], true) . ');';
             $data[] = '$filters[' . var_export($name, true) . '] = $filter;';
         }
     }
     return $this->generate($data, $config);
 }
 public function execute(AgaviXmlConfigDomDocument $DOM)
 {
     $DOM->setDefaultNamespace(self::$NsValidation["ns"], self::$NsValidation["key"]);
     $xpath = $DOM->getXpath();
     $nsVal = self::$NsValidation["key"];
     $nsValURI = self::$NsValidation["ns"];
     $xpath->registerNamespace(self::$NsEnvelope["key"], self::$NsEnvelope["ns"]);
     $validators = $xpath->query("//" . $nsVal . ":validators");
     $params = array();
     foreach ($validators as $val) {
         if ($val->getAttribute("method") && $val->getAttribute("method") != "write") {
             //only respect POST requests
             continue;
         }
         $validators = $xpath->query("//" . $nsVal . ":validator", $val);
         foreach ($validators as $validator) {
             $params[] = $this->parseRequestParameter($validator);
         }
     }
     return $params;
 }
 /**
  * Voer de config handler uit.
  *
  * @param   AgaviXmlConfigDomDocument   $document
  * @return  string                      Data die moet weggeschreven worden
  *                                      naar de cache.
  * @throws  AgaviParseException         Indien de xml file niet geldig is.
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // setting up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'gateways');
     $data = array();
     foreach ($document->getConfigurationElements() as $cfg) {
         if (!$cfg->has('gateways')) {
             continue;
         }
         $gateways = $cfg->get('gateways');
         foreach ($gateways as $gateway) {
             $gn = $gateway->getAttribute('name');
             if (!isset($data[$gn])) {
                 $data[$gn] = array();
             }
             $data[$gn] = $gateway->getAgaviParameters($data[$gn]);
         }
     }
     $code = sprintf('$gatewayRegistry = new KVDutil_GatewayRegistry( new KVDutil_GatewayFactory( %s ) );', var_export($data, true));
     return $this->generate($code, $document->documentURI);
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Sean Kerr <*****@*****.**>
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     Noah Fontes <*****@*****.**>
  * @author     David Zülke <*****@*****.**>
  * @since      0.9.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'autoload');
     $classes = $namespaces = array();
     foreach ($document->getConfigurationElements() as $configuration) {
         if (!$configuration->has('autoloads')) {
             continue;
         }
         // let's do our fancy work
         foreach ($configuration->get('autoloads') as $autoload) {
             // we can have variables in the filename
             $path = AgaviToolkit::expandDirectives($autoload->getValue());
             // sanity check; XML Schema can't do <xs:choice> on attributes...
             if (($isClass = $autoload->hasAttribute('class')) && $autoload->hasAttribute('namespace')) {
                 $error = sprintf('Configuration file "%s" specifies both "class" and "namespace" attribute for path "%s"', $document->documentURI, $path);
                 throw new AgaviParseException($error);
             }
             // prepend the app dir if the path is not absolute
             $file = self::replacePath($path);
             // check if absolute path is readable or try to resolve it against the include path
             if (!file_exists($file) && ($path == $file || !($file = stream_resolve_include_path($path)))) {
                 // the class path doesn't exist and couldn't be resolved against the include path either
                 $error = sprintf('Configuration file "%s" specifies %s "%s" with non-existent path "%s"', $document->documentURI, $isClass ? 'file' : 'namespace', $isClass ? $autoload->getAttribute('class') : $autoload->getAttribute('namespace'), $path);
                 throw new AgaviParseException($error);
             }
             if ($isClass) {
                 // it's a class
                 $classes[$autoload->getAttribute('class')] = $file;
             } else {
                 // it's a whole namespace
                 // trim backslashes from the namespace and trailing slashes or backslashes from the path
                 $namespaces[trim($autoload->getAttribute('namespace'), '\\')] = rtrim($file, '/\\');
             }
         }
     }
     $code = array('AgaviAutoloader::addClasses(' . var_export($classes, true) . ');', 'AgaviAutoloader::addNamespaces(' . var_export($namespaces, true) . ');');
     return $this->generate($code, $document->documentURI);
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviUnreadableException</b> If a requested configuration 
  *                                             file does not exist or is not
  *                                             readable.
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     David Zülke <*****@*****.**>
  * @since      0.11.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'routing');
     $routing = AgaviContext::getInstance($this->context)->getRouting();
     // reset the stored route names
     $this->unnamedRoutes = array();
     // clear the routing
     $routing->importRoutes(array());
     foreach ($document->getConfigurationElements() as $cfg) {
         if ($cfg->has('routes')) {
             $this->parseRoutes($routing, $cfg->get('routes'));
         }
     }
     // we cannot do this:
     // $code = '$this->importRoutes(unserialize(' . var_export(serialize($routing->exportRoutes()), true) . '));';
     // return $this->generate($code, $document->documentURI);
     // because var_export() incorrectly escapes null-byte sequences as \000, which results in a corrupted string, and unserialize() doesn't like corrupted strings
     // this was fixed in PHP 5.2.6, but we're compatible with 5.2.0+
     // see http://bugs.php.net/bug.php?id=37262 and http://bugs.php.net/bug.php?id=42272
     return serialize($routing->exportRoutes());
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Sean Kerr <*****@*****.**>
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     Noah Fontes <*****@*****.**>
  * @since      0.9.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'autoload');
     $data = array();
     foreach ($document->getConfigurationElements() as $configuration) {
         if (!$configuration->has('autoloads')) {
             continue;
         }
         // let's do our fancy work
         foreach ($configuration->get('autoloads') as $autoload) {
             // we can have variables in the filename
             $file = AgaviToolkit::expandDirectives($autoload->getValue());
             // we need the filename w/o app dir prepended since the file could
             // be placed in the include path
             $originalFile = $file;
             // if the filename is not absolute we assume its relative to the app dir
             $file = self::replacePath($file);
             $class = $autoload->getAttribute('name');
             if (!($fp = @fopen($file, 'r', true))) {
                 if ($originalFile != $file && ($fpOriginal = @fopen($originalFile, 'r', true))) {
                     $file = $originalFile;
                     $fp = $fpOriginal;
                 } else {
                     // the class path doesn't exist
                     $error = 'Configuration file "%s" specifies class "%s" with ' . 'nonexistent or unreadable file "%s"';
                     $error = sprintf($error, $document->documentURI, $class, $file);
                     throw new AgaviParseException($error);
                 }
             }
             fclose($fp);
             $data[$class] = $file;
         }
     }
     $code = array('return ' . var_export($data, true) . ';');
     return $this->generate($code, $document->documentURI);
 }
 /**
  * Transform a node with a stylesheet.
  *
  * @param      DOMNode The node to transform.
  *
  * @return     AgaviXmlConfigDomDocument The resulting DOMDocument.
  *
  * @author     Noah Fontes <*****@*****.**>
  * @author     David Zülke <*****@*****.**>
  * @since      1.0.0
  */
 public function transformToDoc($doc)
 {
     $luie = libxml_use_internal_errors(true);
     libxml_clear_errors();
     $result = parent::transformToDoc($doc);
     // check if result is false, too, as that means the transformation failed for reasons like infinite template recursion
     if ($result === false || libxml_get_last_error() !== false || count(libxml_get_errors())) {
         $errors = array();
         foreach (libxml_get_errors() as $error) {
             $errors[] = sprintf('[%s #%d] Line %d: %s', $error->level == LIBXML_ERR_WARNING ? 'Warning' : ($error->level == LIBXML_ERR_ERROR ? 'Error' : 'Fatal'), $error->code, $error->line, $error->message);
         }
         libxml_clear_errors();
         libxml_use_internal_errors($luie);
         throw new Exception(sprintf('Error%s occurred while transforming the document using an XSL stylesheet: ' . "\n\n%s", count($errors) > 1 ? 's' : '', implode("\n", $errors)));
     }
     libxml_use_internal_errors($luie);
     // turn this into an Agavi DOMDocument rather than a regular one
     $document = new AgaviXmlConfigDomDocument();
     $document->loadXML($result->saveXML());
     // save the URI just in case
     $document->documentURI = $result->documentURI;
     unset($result);
     return $document;
 }
 /**
  * (non-PHPdoc)
  * @see AgaviIXmlConfigHandler::execute()
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     $config = basename($document->baseURI, '.xml');
     $refClass = $this->getConfigHandlerClass($config);
     $configHandler = $refClass->newInstance();
     $configHandler->initialize($this->context, $this->parameters);
     $nsprefix = null;
     if ($refClass->hasConstant('XML_NAMESPACE')) {
         $m = array();
         preg_match('/\\/([a-z]+)\\/[^\\/]+$/', $refClass->getConstant('XML_NAMESPACE'), $m);
         $nsprefix = $m[1];
         $document->setDefaultNamespace($refClass->getConstant('XML_NAMESPACE'), $nsprefix);
     } else {
         throw new AgaviConfigurationException('Could not read XML_NAMESPACE from class: ' . $refClass->getName());
     }
     $modules = $this->getAvailableModules();
     $query = $this->getQuery();
     $pointers = $this->getPointers();
     foreach ($modules as $module) {
         $includes = AgaviConfig::get(sprintf(self::INCLUDE_FMT, strtolower($module), $this->getParameter('includeNS', $config)), false);
         if ($includes) {
             if (isset($includes["folder"])) {
                 $includes = $this->resolveFolder($includes);
             }
             foreach ($pointers as $pointer) {
                 AppKitXmlUtil::includeXmlFilesToTarget($document, $query, $pointer, $includes);
                 try {
                     $document->xinclude();
                 } catch (Exception $e) {
                 }
             }
         }
     }
     // The confighandler behind this included definition
     return $configHandler->execute($document);
 }
 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     David Zülke <*****@*****.**>
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     Noah Fontes <*****@*****.**>
  * @since      0.11.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'factories');
     $config = $document->documentURI;
     $data = array();
     // The order of this initialization code is fixed, to not change
     // name => required?
     $factories = array('execution_container' => array('required' => true, 'var' => null, 'must_implement' => array()), 'validation_manager' => array('required' => true, 'var' => null, 'must_implement' => array()), 'dispatch_filter' => array('required' => true, 'var' => null, 'must_implement' => array('AgaviIGlobalFilter')), 'execution_filter' => array('required' => true, 'var' => null, 'must_implement' => array('AgaviIActionFilter')), 'security_filter' => array('required' => AgaviConfig::get('core.use_security', false), 'var' => null, 'must_implement' => array('AgaviIActionFilter', 'AgaviISecurityFilter')), 'filter_chain' => array('required' => true, 'var' => null, 'must_implement' => array()), 'response' => array('required' => true, 'var' => null, 'must_implement' => array()), 'database_manager' => array('required' => AgaviConfig::get('core.use_database', false), 'var' => 'databaseManager', 'must_implement' => array()), 'database_manager', 'logger_manager' => array('required' => AgaviConfig::get('core.use_logging', false), 'var' => 'loggerManager', 'must_implement' => array()), 'logger_manager', 'translation_manager' => array('required' => AgaviConfig::get('core.use_translation', false), 'var' => 'translationManager', 'must_implement' => array()), 'request' => array('required' => true, 'var' => 'request', 'must_implement' => array()), 'routing' => array('required' => true, 'var' => 'routing', 'must_implement' => array()), 'controller' => array('required' => true, 'var' => 'controller', 'must_implement' => array()), 'storage' => array('required' => true, 'var' => 'storage', 'must_implement' => array()), 'storage', 'user' => array('required' => true, 'var' => 'user', 'must_implement' => AgaviConfig::get('core.use_security') ? array('AgaviISecurityUser') : array()), 'translation_manager', 'user', 'routing', 'request', 'controller');
     foreach ($document->getConfigurationElements() as $configuration) {
         foreach ($factories as $factory => $info) {
             if (is_array($info) && $info['required'] && $configuration->hasChild($factory)) {
                 $element = $configuration->getChild($factory);
                 $data[$factory] = isset($data[$factory]) ? $data[$factory] : array('class' => null, 'params' => array());
                 $data[$factory]['class'] = $element->getAttribute('class', $data[$factory]['class']);
                 $data[$factory]['params'] = $element->getAgaviParameters($data[$factory]['params']);
             }
         }
     }
     $code = array();
     $shutdownSequence = array();
     foreach ($factories as $factory => $info) {
         if (is_array($info)) {
             if (!$info['required']) {
                 continue;
             }
             if (!isset($data[$factory]) || $data[$factory]['class'] === null) {
                 $error = 'Configuration file "%s" has missing or incomplete entry "%s"';
                 $error = sprintf($error, $config, $factory);
                 throw new AgaviConfigurationException($error);
             }
             try {
                 $rc = new ReflectionClass($data[$factory]['class']);
             } catch (ReflectionException $e) {
                 $error = 'Configuration file "%s" specifies unknown class "%s" for entry "%s"';
                 $error = sprintf($error, $config, $data[$factory]['class'], $factory);
                 throw new AgaviConfigurationException($error);
             }
             foreach ($info['must_implement'] as $interface) {
                 if (!$rc->implementsInterface($interface)) {
                     $error = 'Class "%s" for entry "%s" does not implement interface "%s" in configuration file "%s"';
                     $error = sprintf($error, $data[$factory]['class'], $factory, $interface, $config);
                     throw new AgaviConfigurationException($error);
                 }
             }
             if ($info['var'] !== null) {
                 // we have to make an instance
                 $code[] = sprintf('$this->%1$s = new %2$s();' . "\n" . '$this->%1$s->initialize($this, %3$s);', $info['var'], $data[$factory]['class'], var_export($data[$factory]['params'], true));
             } else {
                 // it's a factory info
                 $code[] = sprintf('$this->factories[%1$s] = %2$s;', var_export($factory, true), var_export(array('class' => $data[$factory]['class'], 'parameters' => $data[$factory]['params']), true));
             }
         } else {
             if ($factories[$info]['required']) {
                 $code[] = sprintf('$this->%s->startup();', $factories[$info]['var']);
                 array_unshift($shutdownSequence, sprintf('$this->%s', $factories[$info]['var']));
             }
         }
     }
     $code[] = sprintf('$this->shutdownSequence = array(%s);', implode(",\n", $shutdownSequence));
     return $this->generate($code, $config);
 }