Creating an Installable Package That Copies Files
Overview
This is an overview of how to create a module loadable package that will copy files into your instance of Sugar. This is most helpful when your instance is hosted in Sugar's cloud environment or by a third party. For more details on the $manifest
or $installdef
options, you can visit the Introduction to the Manifest. This example package can be downloaded here.
Manifest Example
<?php
$manifest = array(
'acceptable_sugar_flavors' => array('PRO','ENT','ULT'),
'acceptable_sugar_versions' => array(
'exact_matches' => array(),
'regex_matches' => array('(.*?)\\.(.*?)\\.(.*?)$'),
),
'author' => 'SugarCRM',
'description' => 'Copies my files to custom/src/',
'icon' => '',
'is_uninstallable' => true,
'name' => 'Example File Installer',
'published_date' => '2018-06-29 00:00:00',
'type' => 'module',
'version' => '1.0.0',
);
$installdefs = array(
'id' => 'package_1530305622',
'copy' => array(
0 => array(
'from' => '<basepath>/Files/custom/src/MyLibrary/MyCustomClass.php',
'to' => 'custom/src/MyLibrary/MyCustomClass.php',
),
),
);
Copied File Example
This example copies a file to ./custom/src/MyLibrary/MyCustomClass.php
, which adds the custom namespaced class Sugarcrm\Sugarcrm\custom\MyLibrary\MyCustomClass
to the application.
<?php
namespace Sugarcrm\Sugarcrm\custom\MyLibrary;
use \Sugarcrm\Sugarcrm\Logger\Factory;
class MyCustomClass
{
public function MyCustomMethod($message = 'relax')
{
$logger = Factory::getLogger('default');
$logger->info('MyCustomClass says' . "'{$message}'");
}
}