Menu

Hooks

Zitec COM Bogdan Grigore
Attachments
hooks_section-2.jpg (155773 bytes)

Hooks

In order to allow on-demand scripts execution within Codepax, a basic hook system was set to place.

Basically when the Hooks are activated(by setting the "USE_HOOKS" constant to "true") a Hooks section will appear on the interface and all the found hooks will be listed there.

foobar


How to use hooks

The hooks must be placed under "/hooks/" directory which is relative to Codepax directory structure
every hook must exist within a directory, let's say "SampleHook"
the hook directory must contain at least the:
hook file named "Handler.php"
with the class name, in this case "SampleHook_Handler.php"
the hook class must implement the "CodePax_Hooks_Interface"
you can place other files too under hook directory


Sample Hook File

Below you can find a sample hook file:

<?php
class SampleHook_Handler implements CodePax_Hooks_Interface {

    /**
     * Executes the hook
     * 
     * @return void
     * */
    public function run() {
        sleep(2);
    }

    /**
     * Returns the output provided
     * by the hook
     * 
     * @return mixed
     * */
    public function getOutput() {
        return 'sample hook output';
    }

}

Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.