/** * 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; }
/** * Initializes the node with the value. * * @param \TechDivision\Configuration\Interfaces\ConfigurationInterface $configuration The configuration instance * * @return void */ public function initFromConfiguration(ConfigurationInterface $configuration) { $this->value = $configuration->getValue(); }