protected function encode($fieldsDef, $modelSection) { $encoded = ''; foreach ($fieldsDef as $field => $definition) { if (isset($modelSection->{$field})) { $format = $definition['picture']; $encoded .= Picture::encode($modelSection->{$field}, $format, array('field_desc' => $field)); } } return $encoded; }