public function persist() { $data = $this->getFullStatus(); $xml = Ezer_Config::createFromArray($data); $path = $this->path; if ($this->debugPath) { $path = str_replace('.xml', '.' . $this->debugIndex++ . '.xml', $this->path); } $xml->saveXml($path); }
private function mapConfig(Ezer_Config $config) { if (!isset($this->xml_map[$config->entityName])) { throw new Ezer_XmlPersistanceElementNotMappedException($config->entityName); } $class = $this->xml_map[$config->entityName]; if (!class_exists($class)) { throw new Ezer_XmlPersistanceMissingClassException($class); } if (isset($config['id'])) { $this->unique_id = $config['id']; } $object = new $class($this->unique_id++); if ($config->type == Ezer_Config::ARRAY_TYPE) { foreach ($config as $attribute => $value) { if (!is_numeric($attribute)) { continue; } if ($config->{$attribute} instanceof Ezer_Config) { $object->add($this->mapConfig($value)); } else { $object->add($value); } } } $attributes = $config->getKeys(); foreach ($attributes as $attribute) { if ($attribute == 'id') { continue; } if ($config->type == Ezer_Config::ARRAY_TYPE && is_numeric($attribute)) { continue; } if ($config->{$attribute} instanceof Ezer_Config) { $object->{$attribute} = $this->mapConfig($config->{$attribute}); } else { $object->{$attribute} = $config->{$attribute}; } } if ($object instanceof Ezer_Loadable) { $object->validate(); } return $object; }
<?php error_reporting(E_ALL); require_once 'bootstrap.php'; $config = Ezer_Config::createFromPath('config.xml'); Propel::setConfiguration($config->database->toArray()); Propel::initialize(); // insert process $variable1 = new Ezer_Variable(); $variable1->setName('title'); $variable1->setType('string'); $variable2 = new Ezer_Variable(); $variable2->setName('counter'); $partTitle = new Ezer_Variable(); $partTitle->setName('title'); $partTitle->setType('string'); $variable2->parts[] = $partTitle; $partCounts = new Ezer_Variable(); $partCounts->setName('counts'); $partCounts->setType('array'); $variable2->parts[] = $partCounts; $partArray = new Ezer_Variable(); $partCounts->parts[] = $partArray; $partStart = new Ezer_Variable(); $partStart->setName('start'); $partStart->setType('int'); $partArray->parts[] = $partStart; $partStop = new Ezer_Variable(); $partStop->setName('stop'); $partStop->setType('int'); $partArray->parts[] = $partStop;
private function parseFile($file) { $config = Ezer_Config::createFromPath($file); $this->cases[] = $this->mapConfig($config); }
<?php require_once dirname(__FILE__) . '/../../bootstrap.php'; $config = Ezer_Config::createFromPath(dirname(__FILE__) . '/../../config/ajax.xml'); Propel::setConfiguration($config->database->toArray()); Propel::initialize(); $uri = $_SERVER['REQUEST_URI']; EzerAjaxFrontController::run($uri);
protected function getNodeValue(DOMNode $node) { if ($node->hasAttributes()) { return Ezer_Config::createFromNode($node); } if ($node->childNodes->length > 1 || $node->firstChild->nodeType != Ezer_Config::TEXT_NODE_TYPE) { return Ezer_Config::createFromNode($node); } return $this->getTextValue($node); }