PHP Classes

File: demos/actions_closures.php

Recommend this page to a friend!
  Classes of Johnny Mast   PHP Filters and Actions   demos/actions_closures.php   Download  
File: demos/actions_closures.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: 400 bytes
 

Contents

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

use
Redbox\Hooks\Actions;

require
'autoload.php';

Actions::addAction('hello_world', function () {
    echo
"The callback is called\n";
});

/**
 * Result should be:
 *
 * The callback is called
 *
 */
Actions::doAction('hello_world');

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