/** * Normalizes the passed configuration node and returns a \stdClass * representation of it. * * @param \TechDivision\Configuration\Interfaces\ConfigurationInterface $configuration The configuration node to normalize * * @return \stdClass The normalized configuration node */ public function normalize(ConfigurationInterface $configuration) { // initialize the \stdClass instance $node = $this->newInstance('\\stdClass'); $node->{$configuration->getNodeName()} = new \stdClass(); // set the node value if available if ($value = $configuration->getValue()) { $node->{$configuration->getNodeName()}->value = $value; } // set members by converting camel case to underscore (necessary for ember.js) foreach ($configuration->getAllData() as $member => $value) { $node->{$configuration->getNodeName()}->{strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $member))} = $value; } // return the normalized node instance return $node; }
/** * Return's the configuration node name by given mapping and configuration * * @param \TechDivision\Configuration\ConfigurationInterface $configuration The configuration instance * @param \TechDivision\ApplicationServer\Api\Node\Mapping $mapping The mapping instance * * @return string */ public function getConfigurationNodeName(ConfigurationInterface $configuration, Mapping $mapping) { $parts = array(); $parts[] = $configuration->getNodeName(); if ($part = $mapping->getNodeName()) { $parts[] = $part; } return '/' . implode('/', $parts); }