/** * Returns the children (components) from passed component. * * @param Doozr_Form_Service_Component_Formcomponent $component Component to return children for. * @param array $result Resulting array (used for recursion). * * @author Benjamin Carl <*****@*****.**> * * @return array Child components of passed form */ protected function getComponents(Doozr_Form_Service_Component_Formcomponent $component, array $result = []) { /* * Check if the component has any children... Why do we exclude container components here? Easy to understand * we have currently only one component which is a container containing child elements * <select> * <optgroup> * <option></option> * </optgroup> * </select> * So we would iterate its children on the search for value & validation but this does not make sense. One * possible way for a good refactoring would be an interface and a check for instanceof ... So we would * exclude some elements by its interface or exclude others for their. */ if (true === $component->hasChildren() && Doozr_Form_Service_Constant::COMPONENT_CONTAINER !== $component->getType()) { foreach ($component as $child) { $result = $this->getComponents($child, $result); } } elseif (null !== $component->getName()) { $result[$component->getName()] = ['validation' => $component->getValidation(), 'type' => $component->getType()]; } return $result; }