The optional formatter components are used by the connector framework to render a widget that may display additional details and information. Currently, they are shown in the detail view screens for modules that are enabled for the connector. Similar to the source class, the formatter class has a corresponding factory class (FormatterFactory). The formatters also follow the same convention of using the “ext_rest_” or “ext_soap_” prefix. However, to distinguish conflicting class names, a suffix “_formatter” is also used. Formatters extend from default_formatter. Retrieving a formatter instance is similar to retrieving a source instance except that the FormatterFactory scans in order the ./modules/Connectors/connectors/formatters first and then the ./custom/modules/Connectors/connectors/formatters directories.

The following class diagram shows an example of the LinkedIn formatter extending from the default formatter.

Here, we have a subclass ext_rest_linkedin_formatter that overrides the getDetailViewFormat and getIconFilePath methods.
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/connectors/formatters/default/formatter.php');
class ext_rest_linkedin_formatter extends default_formatter {
public function getDetailViewFormat() {
$mapping = $this->getSourceMapping();
$mapping_name = !empty($mapping['beans'][$this->_module]['name']) ? $mapping['beans'][$this->_module]['name'] : '';
if(!empty($mapping_name)) {
$this->_ss->assign('mapping_name', $mapping_name);
return $this->fetchSmarty();
}
$GLOBALS['log']->error($GLOBALS['app_strings']['ERR_MISSING_MAPPING_ENTRY_FORM_MODULE']);
return '';
}
public function getIconFilePath() {
return 'modules/Connectors/connectors/formatters/ext/rest/linkedin/tpls/linkedin.gif';
}
}
The default_formatter class provides an implementation of the getDetailViewFormat method. This method is responsible for rendering the hover code that appears next to certain Detail View fields. The default_formatter class will scan the tpls directory for a Smarty template file named after the module that is being viewed. For example, the file *formatters/ext/rest/linkedin/tpls/Accounts.tpl will be used for the Accounts popup view if the file exists. If the module named template file is not found, it will attempt to use a file named default.tpl.
Formatters are invoked from the Smarty template code, which in turn uses Smarty plugins to call the Formatter classes. The following sequence diagram illustrates this.
