/** * Initialize object from input array. * For each array field will be called property setter. * If the setter is not found, and $failOnUnknownField = true, * exception will be trown. * * :NOTICE: Imenem 20.06.13 * * Every child class can have own logic * to find setter by array field name * * @param array $array Input array with object data * @param boolean $failOnUnknownField If true, exception will be trown if the setter is not found * * @throws RuntimeException Setter is not found */ public function __construct($array = array(), $failOnUnknownField = true) { foreach ($array as $fieldName => $fieldValue) { $propertyName = $this->getPropertyByField($fieldName); PropertyAccessor::setValue($this, $propertyName, $fieldValue, $failOnUnknownField); } }