# FormBuilder.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2007-2008 by Ivan Y. Khvostishkov                       *
    00004  *                                                                         *
    00005  *   This program is free software; you can redistribute it and/or modify  *
    00006  *   it under the terms of the GNU Lesser General Public License as        *
    00007  *   published by the Free Software Foundation; either version 3 of the    *
    00008  *   License, or (at your option) any later version.                       *
    00009  *                                                                         *
    00010  ***************************************************************************/
    00011
    00012     abstract class FormBuilder extends PrototypedBuilder
    00013     {
    00017         protected function createEmpty()
    00018         {
    00019             return Form::create();
    00020         }
    00021
    00025         public function fillOwn($object, &$result)
    00026         {
    00027             Assert::isInstance($result, 'Form');
    00028
    00029             foreach ($this->getFormMapping() as $primitive) {
    00030                 if (
    00031                     $primitive instanceof PrimitiveForm
    00032                     && $result->exists($primitive->getName())
    00033                     && $primitive->isComposite()
    00034                 ) {
    00035
    00036                     Assert::isEqual(
    00037                         $primitive->getProto(),
    00038                         $result->get($primitive->getName())->getProto()
    00039                     );
    00040
    00041                     continue;
    00042                 }
    00043
    00044                 $result->add($primitive);
    00045             }
    00046
    00047             $result = parent::fillOwn($object, $result);
    00048
    00049             $result->setProto($this->proto);
    00050
    00051             return $result;
    00052         }
    00053     }
    00054 ?>