Skip to content

5 Module structure

Juan Morales edited this page Feb 19, 2021 · 2 revisions

The Module

Interface

These is the structure a module has to respect in order to proprly work inside the system.

<?php

namespace Footprint\Interfaces;

use Footprint\Tracker;

interface IModule
{
    /*
     * Every module is expected to have a unique ID.
     */
    public function getId();

    /*
     * If the module is responsibl to generate data that will be part of a log record,
     * then this method returns the data-keys that will be use
     */
    public function getKeys() : array;

    /**
     * The following methods are invoked from the Tracker to the Module.
     * They are self explanatory.
     *
     * Each one of them receives an instance of the Tracker that called the module, so
     * the module can participate building log data, etc.
     */
    public function onInit(Tracker &$tracker);

    public function onEnd(Tracker &$tracker);

    public function onLoad(Tracker &$tracker);

    public function onUnload(Tracker &$tracker);

    public function onLog(Tracker &$tracker);

    public function onLogBuild(Tracker &$tracker);
}