New developer features in Elentra ME 1.22

Highlights from the release

You can find below a list of highlights for significant code changes, or new additions that developers may find useful.

Events Meta data

The Core team has added a new table to store Event meta data. The table will store the Event ID, a Meta Key and a Meta Value. Moving forward, please leverage this table for adding new properties to events, rather than adding a new column in the events table.

Please note that Events Meta Data is an ideal storage location for data. However, if you are storing complex data that has relationships, the recommendation is to create a new table. Meta is not the best solution for data that requires multiple joins of the table on itself.

Event ID: 9 Meta Key: alternate_url Meta Value: https://something.com

Append/Remove ENUM Entries

The Core Team has etended the Migration Model to include new methods allowing developers to easily modify ENUM fields. Altering an ENUM can be problamatic and this simplifies things.

// Example usage
$migrate = new Models_Migration();

// Add an ENUM value
// Assume that Enum values are currently ["blue", "green", "yellow"]
$migrate->addEnumValue("my_database", "my_table", "my_enumerated_field", "black");
// Enum values are now ["blue", "green", "yellow", "black"]

// Remove an ENUM value
$migrate->removeEnumValue("my_database", "my_table", "my_enumerated_field", "green");
// This did nothing because you can only remove the last item in the enumeration
$migrate->removeEnumValue("my_database", "my_table", "my_enumerated_field", "black");
// Enum values are now ["blue", "green", "yellow"]
$migrate->removeEnumValue("my_database", "my_table", "my_enumerated_field", "yellow");
// Enum values are now ["blue", "green"]

Elentra ME Hooks

Hooks allow developers to add functionality to Elentra without changing the Core codebase. Hooks give you the flexibility to extend parts of Elentra, and maintain the code in your branded editiion of the software.

The Core Team has created a basic hook system that allows you to insert calls to certain actions in a standardized way.

To implement hooks, you need create a functions-custom.inc.php in the same directory as Elentra's functions.inc.php file

// Example code in functions-custom.inc.php
// this example will inject 
function dashboard_customize_calendar($active_tab) {
    echo 'The current active tab: ' . $active_tab;
}
Entrada_Hooks::addAction('dashboard_before_calendar', 'dashboard_customize_calendar');

Create your own hook

Step 1

Define your hook in Entrada_Hooks

private static $actions = [
    // Dashboard
    'dashboard_calendar_before' => [],
    'dashboard_calendar_after' => []
    // define your own hook here, using this pattern
    // module_component_location_duration
    // example
    // user_edit_form_submit => []
];  

Step 2

Navigate to the file where you want to execute your own custom code, and define a hook execution, also pass the hook any parameters that you want (single parameter, or array of parameters)

Entrada_Hooks::doAction('dashboard_calendar_before', $active_tab);

Step 3

Navigate to functions-custom.inc.php and add an action to the hook

function dashboard_customize_calendar($active_tab) {
    echo 'The current active tab: ' . $active_tab;
}
Entrada_Hooks::addAction('dashboard_calendar_before', 'dashboard_customize_calendar');

Temporary Storage

The Elentra Corporation has added a new location to store temporary data. It is highly recommended that you create this new folder on your staging and production servers in /var/www/vhosts/host/storage/tmp

// This has been added to settings.inc.php
define("TMP_STORAGE_PATH", $config->entrada_storage . "/tmp"); 

Websockets

The Core Team has added Laravel Websockets to the Elentra API - Jira Ticket

Websockets open a connection through which your frontend and backend can interact in real-time. This will be used in the new Peer Instruction feature that's currently being worked on.

Working with Settings within the Laravel API

The Core team has added a service for retrieving data from the settings table using these simple methods. Please note that this only works while working within elentra-1x-api

// Read information from a setting
Settings::read('key');

// Update a specific setting
Settings::write('key', 'somevalue');

Settings Descriptions

A small, yet very nice improvement, the Settings table now includes a Description column. Developers are now required to add a description to explain what the setting does.

See ME-5351 for more details.

Last updated