SugarCRM SupportDocumentationSugar DeveloperSugar Developer Guide 9.0ArchitectureExtensionsExtensions

Extensions

Overview

This extension allows for developers to create custom extensions within the framework. Custom extensions are used alongside the extensions found in ./ModuleInstaller/extensions.php.

Properties

The following extension properties are available. For more information, please refer to the Extension Property documentation.

Property Value
Extension Scope Application
Sugar Variable $extensions
Extension Directory ./custom/Extension/application/Ext/Extensions/
Compiled Extension File ./custom/application/Ext/Extensions/extensions.ext.php
Manifest Installdef $installdefs['extensions']

Parameters

  • section : Section name in the manifest file
  • extdir : The directory containing the extension files
  • file : The name of the file where extension files are compiled into
  • module : Determines how the framework will interpret the extension (optional)
    • <Empty> : Will enable the extension for all modules
      • Ext : ./custom/Extension/modules/<module>/Ext/<Custom Extension>/
      • Ext File : ./custom/modules/<module>/Ext/<Extension Name>.ext.php
    • <Specific Module> : Will enable the extension for the specified module
      • Ext Directory : ./custom/Extension/modules/<Specific Module>/Ext/<Custom Extension>/
      • Ext File : ./custom/modules/<Specific Module>/Ext/<Extension Name>.ext.php
    • Application : enables the extension for application only
      • Ext Directory : ./custom/Extension/application/Ext/<Custom Extension>/
      • Ext File : ./custom/application/Ext/<Custom Extension>/<Extension Name>.ext.php

Implementation

The following sections illustrate the various ways to implement a customization to a Sugar instance.

File System

When working directly with the filesystem, you can create a file in ./custom/Extension/application/Ext/Extensions/ to map a new extension in the system. The following example will create a new extension called "example", which is only enabled for "application":

./custom/Extension/application/Ext/Extensions/<file>.php

<?php

$extensions['example'] = array(
    'section' => 'example',
    'extdir' => 'Example',
    'file' => 'example.ext.php',
    'module' => 'application' //optional paramater
);

Next, navigate to Admin > Repair > Quick Repair and Rebuild. The system will rebuild the extensions and compile your customization into ./custom/application/Ext/Extensions/extensions.ext.php. Then you will be able to add your own extension files in  ./custom/Extension/application/Ext/Example/.

Module Loadable Package

When building a module loadable package, you can use the $installdefs['extensions'] index to install the extension file.

Installdef Properties

Name Type Description
from String The base path of the file to be installed

The example below will demonstrate the proper install definition that should be used in the ./manifest.php file in order to add the Extension file to the system. You should note that when using this approach, Sugar will automatically execute Rebuild Extensions to reflect the new Extension in the system.

./manifest.php

<?php

$manifest = array(
    ...
);

$installdefs = array(
    'id' => 'customExtension_Example',
    'extensions' => array(
        array(
            'from' => '<basepath>/Files/custom/Extension/application/Ext/Extensions/<file>.php'
        )
    )
);

Alternatively, you may use the $installdefs['copy'] index for the Extension file. When using this approach, you may need to manually run repair actions such as a Quick Repair and Rebuild. For more information on the $installdefs['copy'] index and module-loadable packages, please refer to the Introduction to the Manifest page.

Last modified: 2019-03-13 02:04:19