/** * Hydrate $object with the provided $data. * * @param array $data * @param object $object * @return object */ public function hydrate(array $data, $object) { if (isset($data['properties']) && is_array($data['properties'])) { foreach ($data['properties'] as $key => $value) { $newKey = String::decamelize($key); if ($newKey != $key) { $data['properties'][$newKey] = $value; unset($data['properties'][$key]); } } } return $this->getMapper()->hydrate($data, $object); }
/** * Get property priority * * @param string $name * @return mixed */ public function getPropertyPriority($name) { return $this->getRawPropertyPriority(String::decamelize($name)); }
/** * Reflect css properties * * @param \Zend\Form\FieldsetInterface $fieldset * @param string $selector * @return \Zend\Form\FieldsetInterface */ protected function reflectCss(FieldsetInterface $fieldset, $selector) { foreach ($fieldset->getFieldsets() as $subFieldset) { if (!$subFieldset instanceof Collection) { $this->reflectCss($subFieldset, $selector); } } foreach ($fieldset->getElements() as $name => $element) { $types = array_filter(preg_split('/\\s+/', trim($element->getAttribute('data-js-type')))); $types[] = 'js.paragraph.reflectCss'; $element->setAttributes(array('data-js-type' => implode(' ', $types), 'data-js-reflectcss-selector' => $selector, 'data-js-reflectcss-property' => String::decamelize($name))); } return $fieldset; }
/** * Test decamelize */ public function testDecamelize() { $this->assertEquals('camel-ized-words', String::decamelize('CamelIzedWords')); $this->assertEquals('camel.ized.words', String::decamelize('CamelIzedWords', '.')); }