Index: branches/5.2.x/core/kernel/kbase.php =================================================================== diff -u -N -r16513 -r16709 --- branches/5.2.x/core/kernel/kbase.php (.../kbase.php) (revision 16513) +++ branches/5.2.x/core/kernel/kbase.php (.../kbase.php) (revision 16709) @@ -1,6 +1,6 @@ GetDBField($name); - /** @var kFormatter $formatter */ - $formatter = $this->Application->recallObject($formatter_class); - - return $formatter->Format($value, $name, $this, $format); + return $this->getFormatter($formatter_class)->Format($value, $name, $this, $format); } return $this->GetDBField($name); @@ -933,10 +937,9 @@ foreach ($fields as $field) { if ( isset($this->Fields[$field]['formatter']) ) { - /** @var kFormatter $formatter */ - $formatter = $this->Application->recallObject($this->Fields[$field]['formatter']); - - $formatter->UpdateSubFields($field, $this->GetDBField($field), $this->Fields[$field], $this); + $this + ->getFormatter($this->Fields[$field]['formatter']) + ->UpdateSubFields($field, $this->GetDBField($field), $this->Fields[$field], $this); } } } @@ -955,11 +958,26 @@ continue; } - /** @var kFormatter $formatter */ - $formatter = $this->Application->recallObject( $this->Fields[$field_name]['formatter'] ); + $this + ->getFormatter($this->Fields[$field_name]['formatter']) + ->PrepareOptions($field_name, $this->Fields[$field_name], $this); + } + } - $formatter->PrepareOptions($field_name, $this->Fields[$field_name], $this); + /** + * Returns formatter. + * + * @param string $name Name. + * + * @return kFormatter + */ + protected function getFormatter($name) + { + if ( !isset(self::$_formattersCache[$name]) ) { + self::$_formattersCache[$name] = $this->Application->recallObject($name); } + + return self::$_formattersCache[$name]; } /**