Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * Constructor.
  *
  * @param Doozr_Form_Service_Renderer_Interface $renderer Renderer instance for rendering this component
  * @param Doozr_Form_Service_Component_Legend   $legend   The legend to add
  *
  * @author Benjamin Carl <*****@*****.**>
  *
  * @return \Doozr_Form_Service_Component_Fieldset
  */
 public function __construct(Doozr_Form_Service_Renderer_Interface $renderer = null, Doozr_Form_Service_Component_Legend $legend = null)
 {
     if ($legend !== null) {
         $this->setLegend($legend);
     }
     // Important call so observer storage ... can be initiated
     parent::__construct($renderer);
 }
Example #3
0
 /**
  * Renders a component a returns it HTML code.
  *
  * @param bool $force TRUE to re-render a already rendered component,
  *                    otherwise FALSE to use cached result if exist
  *
  * @author Benjamin Carl <*****@*****.**>
  *
  * @return string|null A string containing the resulting HTML code,
  *                     NULL on error
  */
 public function render($force = false)
 {
     // Do custom sort and stuff like this and proxy forward the call to render to renderer->render(...)
     $this->setChildren($this->sort($this->order));
     // Return the rendered result
     return parent::render($force);
 }
Example #4
0
 /**
  * Constructor.
  *
  * @param Doozr_Form_Service_Renderer_Interface $renderer Renderer instance for rendering this component
  * @param string                                $message  The message to set
  *
  * @author Benjamin Carl <*****@*****.**>
  *
  * @return \Doozr_Form_Service_Component_Legend
  */
 public function __construct(Doozr_Form_Service_Renderer_Interface $renderer = null, $message = null)
 {
     if ($message !== null) {
         $this->setInnerHtml($message);
     }
     // Important call so observer storage ... can be initiated
     parent::__construct($renderer);
 }
Example #5
0
 /**
  * Constructor.
  *
  * @param Doozr_Form_Service_Renderer_Interface  $renderer  Renderer instance for rendering this component
  * @param Doozr_Form_Service_Validator_Interface $validator Validator instance for validating this component
  * @param string|null                            $name      Name/identifier of form
  *
  * @author Benjamin Carl <*****@*****.**>
  */
 public function __construct(Doozr_Form_Service_Renderer_Interface $renderer = null, Doozr_Form_Service_Validator_Interface $validator = null, $name = null)
 {
     if (null !== $name) {
         $this->setName($name);
     }
     // Important call so observer storage ... can be initiated
     parent::__construct($renderer, $validator);
 }
Example #6
0
 /**
  * Constructor.
  *
  * @param Doozr_Form_Service_Renderer_Interface $renderer Renderer instance for rendering this component
  *
  * @author Benjamin Carl <*****@*****.**>
  *
  * @return \Doozr_Form_Service_Component_Div
  */
 public function __construct(Doozr_Form_Service_Renderer_Interface $renderer = null)
 {
     // Important call so observer storage ... can be initiated
     parent::__construct($renderer);
 }