Skip to content

Installation

jcsmorais edited this page Jul 3, 2012 · 4 revisions

The easiest way to install the Insulin library is to download the package and save it on the custom/library/Insulin folder.

Currently there are two ways of accomplishing this, it actually depends on the version you're developing on.

Sugar < 6.5.0

Before Sugar 6.5.0 there was no support for the on-load inclusion of specific files, the upgrade-safe way. With this in mind, we choose the entry point to do it, but with a tiny core-fix, in order to allow one to define it in an upgrade-safe way.

The code below should be appended to include/entryPoint.php file:

if (is_file('custom/include/entryPoint.php')) {
    require_once 'custom/include/entryPoint.php';
}

After this, in order to enable Insulin library bootstrap Sugar wide, you need to add the code below to the custom entry point in custom/include/entryPoint.php.

<?php

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

require_once 'custom/library/Insulin/Bootstrap.php';
$bootstrap = new Insulin_Bootstrap();
$bootstrap->run();

And you're good to go.

Sugar >= 6.5.0

On Sugar 6.5.0 a new logic hook was introduced, the after_entry_point, which eases the inclusion of Insulin Bootstrap. To take advantage of this new feature, you have to add (or append) the code below to the custom/modules/logic_hooks.php file:

<?php

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

$hook_array = array();
$hook_array['after_entry_point'] = array();
$hook_array['after_entry_point'][] = array(
    1,
    'Initialize Insulin Library Bootstrap.',
    'custom/modules/EntryPointLogic.php',
    'EntryPointLogic',
    'initInsulin'
);

And then call the Insulin Bootstrap on the new logic file defined custom/modules/EntryPointLogic.php:

<?php

class EntryPointLogic
{

    public function initInsulin()
    {
        require_once 'custom/library/Insulin/Bootstrap.php';
        $bootstrap = new Insulin_Bootstrap();
        $bootstrap->run();
    }

}

And you're good to go.

Clone this wiki locally