PHP Classes

File: demos/actions_functions.php

Recommend this page to a friend!
  Classes of Johnny Mast   PHP Filters and Actions   demos/actions_functions.php   Download  
File: demos/actions_functions.php
Role: Example script
Content type: text/plain
Description: Auxiliary script
Class: PHP Filters and Actions
Listen to events and execute registered actions
Author: By
Last change:
Date: 6 years ago
Size: 580 bytes
 

Contents

Class file image Download
<?php
namespace Sandbox\Demos;

require
'autoload.php';

use
Redbox\Hooks\Actions;

function
helloWorld($text)
{
    echo
$text . "\n";
}

/**
 * If you are using your own custom namespace it is highly important
 * to prefix your functions with a the correct namespace.
 */
Actions::AddAction('hello_world', 'Sandbox\Demos\helloWorld');
Actions::doAction('hello_world', 'Hello World');

/**
 * The result should be:
 *
 * Result: Hello World
 *
 */

/**
 * This is not required in your code. I have to add this to reset my unit tests.
 */
Actions::removeAllActions('hello_world');