Let the platform do the work

Platforms

Overview

The Platforms extension adds allowed REST API platforms when restricting custom platforms through the use of the disable_unknown_platforms configuration setting.

Properties

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

Property Value
Extension Scope Application
Extension Directory ./custom/Extension/application/Ext/Platforms/
Compiled Extension File ./custom/application/Ext/Platforms/platforms.ext.php
Manifest Installdef $installdefs['platforms']

Implementation

The following sections illustrate the various ways to implement a new platform type to a Sugar instance.

File System

When working directly with the filesystem, enable the disable_unknown_platforms configuration by setting $sugar_config['disable_unknown_platforms'] = true in your ./config_override.php. This will prevent the system from allowing unknown platform types from accessing the rest endpoints. Next, create a file in ./custom/Extension/application/Ext/Platforms/ to map a new platform in the system. The following example adds a new platform called 'integration' that can be used throughout the system:

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

<?php

$platforms[] = 'integration';

Finally, navigate to Admin > Repair > Quick Repair and Rebuild. The system will then rebuild the extensions and your customizations will be compiled into ./custom/application/Ext/Platforms/platforms.ext.php.

Alternatively, platforms can also be added by creating ./custom/clients/platforms.php and appending new platform types to the $platforms variable. This method of creating platforms is still compatible but is not recommended from a best practices standpoint.

Once installed, developers can take advantage of the new platform type when authenticating with the REST API oauth2/token endpoint. An example is shown below: 

{
  "grant_type": "password",
  "username": "admin",
  "password": "password",
  "client_id": "sugar",
  "client_secret": "",
  "platform": "integration"
}

Module Loadable Package

When building a module loadable package, you can use the $installdefs['platforms'] 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 demonstrates the proper install definition that should be used in the ./manifest.php file in order to add the utils to the system. You should note that when using this approach, Sugar will automatically execute Rebuild Extensions to reflect the new utils in the system.

./manifest.php

<?php

$manifest = array(
    ...
);

$installdefs = array(
    'id' => 'Platforms_Example',
    'platforms' => array(
        array(
            'from' => '<basepath>/Files/custom/Extension/application/Ext/Platforms/<file>.php',
        )
    )
);

Alternatively, you may use the $installdefs['copy'] index to copy the 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.