Events

Introduction

Events are system events fired in different parts of the system. They are a planned mechanism in which services are provided. Therefore, an event is logging the user in to the system. The authorization process, on the other hand, is not an event at all. The overview of events fired under a component’s structure can be found here.

System Events

The basic events fired by the system are the following:

General
  • antares.ready
  • antares.started: {area} (e.g. antares.started: admin)
  • antares.ready: {area}
  • antares.done: {area}
Installation
  • antares.install.schema
  • antares.install.schema: {name} (e.g. antares.install.schema: multibrand)
  • antares.install: {name}
  • antares.install: {name}
Modules And Components
  • extension.started
  • extension.started: {name} (e.g. extension.started: multibrand)
  • extension.done
  • extension.done: {name}
  • antares.form: extension.{name}
  • antares.validate: extension.{name}
  • antares.saving: extension.{name}
  • antares.saved: extension.{name}
  • antares.activating: {name}
  • antares.deactivating: {name}
Users
  • antares.list: users
  • antares.form: users
  • antares.validate: users
  • antares.creating: users
  • antares.updating: users
  • antares.deleting: users
  • antares.saving: users
  • antares.created: users
  • antares.updated: users
  • antares.deleted: users
  • antares.saved: users
User’s Account Service
  • antares.form: user.account
  • antares.validate: user.account
  • antares.creating: user.account
  • antares.updating: user.account
  • antares.deleting: user.account
  • antares.saving: user.account
  • antares.created: user.account
  • antares.updated: user.account
  • antares.deleted: user.account
  • antares.saved: user.account
System’s Settings
  • antares.form: settings
  • antares.validate: settings
  • antares.saved: settings

Furthermore, the system renders available the following closely related to services:

Datatables

More information about how datatables operate as a service can be found here. A list of events fired under the service:

Adding a column after a column: datatables:{route}:after.{column}. An example:

Event::listen('datatables:admin/users/index:after.id', function($datatables) {
            if ($datatables instanceof Builder) {
                $datatables->collection->push(new Column([
                    'data'  => 'playground',
                    'name'  => 'playground',
                    'title' => 'from playground module'
                ]));
            }
});

Adding a column before a column: datatables:{route}:before.{column}. An example:

Event::listen('datatables:admin/users/index:before.id', function($datatables) {
            if ($datatables instanceof Builder) {
                $datatables->collection->push(new Column([
                    'data'  => 'playground',
                    'name'  => 'playground',
                    'title' => 'from playground module'
                ]));
            }
});

Changing the value of the already existing column: datatables:{route}:column.{column}. An example:

Event::listen('datatables:admin/users/index:column.id', function(&$attributes) {
            if (isset($attributes['title'])) {
                $attributes['title'] = $attributes['title'] . ' - from playground module';
            }
});

Adding an action before the existing position in the row’s context menu: datatables:{route}:before.action.{action}. An example:

Event::listen('datatables:admin/users/index:before.action.edit', function($actions, $row) {
            $actions->push(app('html')->link(handles("antares::users/{$row->id}/playground"), 'From playground module'));
});

The modification of a value in the row’s cell: datatables:rows.{route}. An example:

Event::listen('datatables:rows.admin/users/index', function($row) {
            $row->fullname   = $row->fullname . ' Appends Fullname from Playrgound Module';
            $row->playground = 'Row From Playground Module';
});

Adding a filter to ‘Datatables’ instance: datatables:filters.{route}.{filter}.before. An example:

Event::listen('datatables:filters.admin/users/index.userstatusfilter.before', function($filter) {
            $filter->add(Filter\StatusFilter::class);
});

Widgets

Adding the value before the content rendered by a widget: widgets:render.before.{widget}. An example:

Event::listen('widgets:render.before.userswidget', function() {
                echo '<img src="http://dummyimage.com/600x100/DDD/fff&text=from+playground+module+-+before+widget" />';
    });

Adding the value after the content rendered by a widget: widgets:render.after.{widget}. An example:

Event::listen('widgets:render.after.userswidget', function() {
      echo '<img src="http://dummyimage.com/600x100/DDD/fff&text=from+playground+module+-+after+widget" />';
    });

Adding an action to the action list assigned to a widget: widgets:render.widget-actions.{widget}. An example:

Event::listen('widgets:render.widget-actions.userswidget', function() {
                            echo '<li>
                                <a class="mdl-js-button mdl-js-ripple-effect ajaxable widget-refresh" href="#" title="">
                                    <i class="zmdi zmdi-star"></i>
                                    Im action from playground module
                                </a>
                            </li> ';
    });

Adding the value before the content published by a widget template: widgets:render.before.template.{template}. An example:

Event::listen('widgets:render.before.template.ajax', function() {
    echo 'before render template from module playground';
});

Adding the value after the content published by a widget template: widgets:render.after.template.{template}. An example:

Event::listen('widgets:render.after.template.ajax', function() {
       echo 'after render template from module playground';
});

Attaching a widget into the right gridstack segment: widgets:render.{route}.right. An example:

Event::listen('widgets:render.admin.right', function() {
     $object = app(\Antares\Playground\Widgets\PlaygroundWidget::class);
     $object->setView('antares/widgets::admin.partials._base');
     echo $object;
});

Forms

Attaching a fieldset before the first fieldset in a form: forms:{form_name}.fieldsets.0.before. An example:

Event::listen('forms:user-form.fieldsets.0.before', function($form) {
            $form->fieldset('Playground fieldset before first fieldset', function (\Antares\Html\Form\Fieldset $fieldset) {
                $fieldset->legend('Playground fieldset before first fieldset');
                $fieldset->control('input:text', 'playground_text_field')->label('Playground text field');
            });
});

Attaching a fieldset after the first fieldset in a form: forms:{form_name}.fieldsets.0.after. An example:

Event::listen('forms:user-form.fieldsets.0.after', function($form) {
            $form->fieldset('Appends as last fieldset from playrgound', function (\Antares\Html\Form\Fieldset $fieldset) {
                $fieldset->legend('Appends as last fieldset from playground');
                $fieldset->control('textarea', 'playground_textarea_field')
                        ->label('Playground textarea field');
            });
});

Adding a button before all the buttons in a form: forms:{form_name}.controls.button.before. An example:

Event::listen('forms:user-form.controls.button.before', function($fieldset) {
            $fieldset->control('button', 'before submit')
                    ->value(trans('Before submit button from playground module'))
                    ->attributes(['class' => 'btn btn--md btn--red mdl-button mdl-js-button mdl-js-ripple-effect']);
});

Adding a button after all the buttons in a form: forms:{form_name}.controls.button.after. An example:

Event::listen('forms:user-form.controls.button.after', function($fieldset) {
            $fieldset->control('button', 'after submit')
                    ->value(trans('After submit button from playground module'))
                    ->attributes(['class' => 'btn btn--md btn--orange mdl-button mdl-js-button mdl-js-ripple-effect']);
});

Adding a control after the already existing control: forms:{form_name}.controls.{control_name}.after. An example:

Event::listen('forms:user-form.controls.password.after', function($fieldset) {
            $fieldset->control('select', 'sample-text')
                    ->label('After password field from playground module')
                    ->options(function() {
                        return [
                            '0' => 'First option',
                            '1' => 'Second option',
                            '2' => 'Last option'
                        ];
                    });
});

Adding a control before the already existing control: forms:{form_name}.controls.{control_name}.before. An example:

Event::listen('forms:user-form.controls.email.before', function($fieldset) {
            $fieldset->control('checkbox', 'checkboxes')
                    ->label('Before email field from playground module');
});

Notifications

Adding variables to the notification: notifications:{notification_name}.variables. An example:

Event::listen('forms:user-form.controls.email.before', function($fieldset) {
            $fieldset->control('checkbox', 'checkboxes')
                    ->label('Before email field from playground module');
});

Adding the value before the notification’s content: notifications:{notification_name}.render.before. An example:

Event::listen('notifications:new_device_notification.render.before', function() {
                return '<img src="http://dummyimage.com/600x200/DDD/fff&text=from+playground+module+-+prepends+notification+content"/>';
    });

Adding the value after the notification’s content: notifications:{notification_name}.render.after. An example:

Event::listen('notifications:new_device_notification.render.after', function() {
                return '<img src="http://dummyimage.com/600x200/DDD/fff&text=from+playground+module+-+appends+notification+content"/>';
    });

Analyzer

Adding a tab before the already existing tab in the content of the analyzer’s report (e.g. a module has been installed and it increases the memory demand): analyzer:before.{tab_name}. An example:

Event::listen('analyzer:before.components', function() {
            return [
                'url'         => handles('antares::logger/analyze/playground', ['csrf' => true]),
                'description' => 'Playground analyzer description',
            ];
});