/** * Method to recursively bind data to a parent object. * * @param object $parent The parent object on which to attach the data values. * @param mixed $data An array or object of data to bind to the parent object. * * @return void * @since 1.6 */ protected function bindData(&$parent, $data) { // Ensure the input data is an array. if (is_object($data)) { $data = get_object_vars($data); } else { $data = (array) $data; } foreach ($data as $k => $v) { if (is_array($v) && RokCommon_Utils_ArrayHelper::isAssociative($v) || is_object($v)) { $parent->{$k} = new stdClass(); $this->bindData($parent->{$k}, $v); } else { $parent->{$k} = $v; } } }
/** * Method to bind data to the form for the group level. * * @param string $group The dot-separated form group path on which to bind the data. * @param mixed $data An array or object of data to bind to the form for the group level. * * @return void * * @since 11.1 */ protected function bindLevel($group, $data) { // Ensure the input data is an array. settype($data, 'array'); // Process the input data. foreach ($data as $k => $v) { if ($this->findField($k, $group)) { // If the field exists set the value. $this->data->set($group . '.' . $k, $v); } elseif (is_object($v) || RokCommon_Utils_ArrayHelper::isAssociative($v)) { // If the value is an object or an associative array, hand it off to the recursive bind level method $this->bindLevel($group . '.' . $k, $v); } } }
/** * Sets a service container parameter. * * @param string $name The parameter name * @param $value * * @internal param mixed $parameters The parameter value */ public function setParameter($name, $value) { $cleaned_name = strtolower($name); if (is_array($value) && RokCommon_Utils_ArrayHelper::isAssociative($value)) { foreach ($value as $key => $subvalue) { $subname = $cleaned_name . RokCommon_Registry::SEPARATOR . strtolower($key); $this->setParameter($subname, $subvalue); } } elseif (is_array($value) && $this->parameters->exists($cleaned_name)) { $current = $this->parameters->get($cleaned_name); if (is_array($current)) { $merged = array_merge($current, $value); $this->parameters->set($cleaned_name, $merged); } else { $this->parameters->set($cleaned_name, $value); } } else { $this->parameters->set($cleaned_name, $value); } }