The system features a flexible and extensible framework for configuring Actions, allowing users to define and customize various automated tasks. While a wide range of standard action types with configurable options is already available, the system also supports the development of custom action types to address specific or complex use cases that require bespoke logic beyond standard configurations.
The purpose of custom action types is to provide a flexible mechanism for implementing complex or unique business logic that cannot be efficiently handled by the standard predefined action types. This enables the system to be extended easily to meet specific requirements without compromising performance or maintainability.
Developers can create a new custom action type by running the following command on the server:
php console.php create action Foo
Here, Foo
is the name of the new action type.
This command generates a PHP file on the server with a skeleton class, for example:
<?php
namespace CustomActions;
use Atro\ActionTypes\AbstractAction;
use Atro\Core\EventManager\Event;
use Espo\ORM\Entity;
class Foo extends AbstractAction
{
public static function getTypeLabel(): ?string
{
return 'Foo';
}
public static function getName(): ?string
{
return 'Do Foo';
}
public static function getDescription(): ?string
{
return 'Describe Foo';
}
public function executeNow(Entity $action, \stdClass $input): bool
{
return true;
}
}
Method Signature | Description |
---|---|
getTypeLabel() |
Returns a short label identifying the action type. Example: 'Foo' . |
getName() |
Returns the default name of the Action type. If the user selects this action type but does not provide a custom name, the system uses this value automatically. Example: 'Do Foo' . |
getDescription() |
Returns the default description of the Action type. If the user does not provide a description during creation, the system uses this value. Example: 'Describe Foo' . |
executeNow(Entity $action, \stdClass $input) |
Contains the main execution logic of the action. |
To improve developer experience, the system provides a convenient way to preview the implementation of a custom Action directly from the UI.
This feature is intended to make debugging and reviewing logic easier for developers and administrators.