Customization

Customization

Each customization should be in a base folder custom/Extension/application/Ext/Api/V8/. See more about Slim framework at https://www.slimframework.com.

Extending Slim configuration in custom/application/Ext/Api/V8/slim.php is a native php file should returns an array of slim configurations. Additional configuration will be merged into the default slim configuration.

return [ /* slim configuration here ...*/ ];

Extending Routes in custom/application/Ext/Api/V8/Config/routes.php is a native php file given $app variable as a Slim application. Additional routes will be added into the default slim application and available in URL [SuiteCRM-path]/Api/V8/custom custom/application/Ext/Api/V8/Config/routes.php

$app->post('/my-route/{myParam}', 'MyCustomController:myCustomAction');

Extending Services in custom/application/Ext/Api/V8/services.php is a native php file should returns an array of slim services. Additional services will be merged into the default slim services. custom/application/Ext/Api/V8/services.php

return ['myCustomService' => function() {
    return new MyCustomService();
}];

Extending BeanAliases in custom/application/Ext/Api/V8/beanAliases.php is a native php file should returns an array of custom bean aliases. custom/application/Ext/Api/V8/beanAliases.php

return [MyCustom::class => 'MyCustoms'];

Extending Controllers in custom/application/Ext/Api/V8/controllers.php is a native php file should returns an array of custom controllers. custom/application/Ext/Api/V8/controllers.php

return [MyCustomController::class => function(Container $container) {
    return new MyCustomController();
}];

Extending Factories in custom/application/Ext/Api/V8/factories.php is a native php file should returns an array of custom factories. custom/application/Ext/Api/V8/factories.php

return [MyCustomFactory::class => function(Container $container) {
    return new MyCustomFactory();
}];

Extending Globals in custom/application/Ext/Api/V8/globals.php is a native php file should returns an array of custom globals. custom/application/Ext/Api/V8/globals.php

return [MyCustomGlobal::class => function(Container $container) {
    return new MyCustomFactory();
}];

Extending Helpers in custom/application/Ext/Api/V8/helpers.php is a native php file should returns an array of custom helpers. custom/application/Ext/Api/V8/helpers.php

return [MyCustomHelper::class => function(Container $container) {
    return new MyCustomHelper();
}];

Extending Middlewares in custom/application/Ext/Api/V8/middlewares.php is a native php file should returns an array of custom middlewares. custom/application/Ext/Api/V8/middlewares.php

return [MyCustomMiddleware::class => function(Container $container) {
    return new MyCustomMiddleware();
}];

Extending Params in custom/application/Ext/Api/V8/params.php is a native php file should returns an array of custom params. custom/application/Ext/Api/V8/params.php

return [MyCustomParam::class => function(Container $container) {
    return new MyCustomParam();
}];

Extending Validators in custom/application/Ext/Api/V8/validators.php is a native php file should returns an array of custom validators. custom/application/Ext/Api/V8/validators.php

return [MyCustomValidator::class => function(Container $container) {
    return new MyCustomValidator();
}];

Basic example of API customization

Create a file for new custom route: [SuiteCRM-path]/custom/application/Ext/Api/V8/Config/routes.php with the following content:

<?php
$app->get('/hello', function() {
    return 'Hello World!';
});

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.