Let the platform do the work

Metadata API

Overview

Methods to load metadata for the AutoLoader API.

Metadata Loading

For the specific sets of metadata, such as detailviewdefs, editviewefs, listviewdefs, searchdefs, popupdefs, and searchfields, a special process is used to load the correct metadata file. You should note that the variable name for the defs, e.g. "detailviewdefs", is usually the same as variable name, except in the case of "searchfields" where it is "SearchFields".

The process is described below:

  1. If ./custom/modules/{$module}/metadata/{$varname}.php exists, it is used as the data file.
  2. If ./modules/{$module}/metadata/metafiles.php or ./custom/modules/{$module}/metadata/metafiles.php exists, it is loaded with the custom file being preferred. If the variable name exists in the data specified by the metafile, the corresponding filename is assumed to be the defs file name.
  3. If the defs file name or its custom/ override exists, it is used as the data file (custom one is preferred).
  4. If no file has been found yet, ./modules/{$module}/metadata/{$varname}.php is checked and if existing, it is used as the data file.
  5. Otherwise, no metadata file is used.

loadWithMetafiles($module, $varname)

Returns the specified metadata file for a specific module. You should note that due to the scope nature of include(), this function does not load the actual metadata file but will return the file name that should be loaded by the caller.

  $metadataPath = SugarAutoloader::loadWithMetafiles('Accounts', 'editviewdefs');

loadPopupMeta($module, $metadata = null)

Loads popup metadata for either specified $metadata variable or "popupdefs" variable via loadWithMetafiles() and returns it. If no metadata found returns empty array.

  $popupMetadata = SugarAutoloader::loadPopupMeta('Accounts');

loadExtension($extname, $module = "application")

Returns the extension path given the extension name and module. For global extensions, the module should be "application" and may be omitted. If the extension has its own module, such as schedulers, it will be used instead of the $module parameter. You should note that due to the scope nature of include(), this function does not load the actual metadata file but return the file name that should be loaded by the caller. If no extension file exists it will return false.

  //The list of extensions can be found in ./ModuleInstall/extensions.php
$extensionPath = SugarAutoloader::loadExtension('logichooks');

Topics