# Events

By default the framework will do the basic CRUD operations using the metadata to apply rules and specific behaviours, but sometimes this is not enough and it's needed to make some custom code around a feature.

Let's say we save a project, but we want to notify by email an user that the project was changed. We can't do this with just configurations, but we can make custom code on a specific moment without changing the main flow of the save operation.

On our example we could use the afterUpdate event to send the email, the only thing we need to do is implement the afterUpdate method on the Project schema.


public function afterUpdate(
  $data_array,
  $schema,
  $i,
  $old_object,
  &$response_obj,
  $lang,
  $content_id)
{
  $mailer = new Mailer();
  $result = $mailer->sendEmailTemplate(
    "INTERNAL-MESSAGE-ALERT",
    ["message" => "Project A was changed"],
    [
      [
        $email, $name
      ]
    ]
  );
}

Basically we have events before any processing is made, after validations and processing is made but before the DB transaction or at the very end of the flow after the DB operation occured. More information can be found on the GenericSchema class but the full list of events are:

  • beforeProcessInsert
  • beforeInsert
  • afterInser
  • beforeProcessUpdate
  • beforeUpdate
  • afterUpdate
  • beforeProcessDelete
  • beforeDelete
  • beforeProcessSelect
  • afterSelect
  • beforeProcessSelectById
  • afterSelectById
  • beforePriorityChange
  • afterPriorityChange

There is also some special events that only run when using the API endpoints (not the SDK classes)

  • apiOnlyBeforeSelect
  • apiOnlyAfterSelect
  • apiOnlyBeforeSelectById
  • apiOnlyAfterSelectById
  • apiOnlyBeforeInsert
  • apiOnlyAfterInsert
  • apiOnlyBeforeUpdate
  • apiOnlyAfterUpdate
  • apiOnlyBeforeDelete
  • apiOnlyAfterDelete

Also we can define two specific eventos for export and for very custom combobox datasets by using:

  • exportCSV($schema, $filters = [])
  • getComboboxValues($fieldKey, $params)
Last Updated: 10/12/2021, 3:27:32 PM