PHP Classes

File: demos/actions_priority.php

Recommend this page to a friend!
  Classes of Johnny Mast  >  PHP Filters and Actions  >  demos/actions_priority.php  >  Download  
File: demos/actions_priority.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: 5 years ago
Size: 599 bytes
 

Contents

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

use
Redbox\Hooks\Actions;

require
'autoload.php';

/**
 * This function is going to be called second.
 */
function otherFunction()
{
    echo
"Called second\n";
}

/**
 * This function is going to be called first.
 */
function oneFunction()
{
    echo
"Called first\n";
}

Actions::addAction('say_hello', 'Sandbox\Demos\oneFunction', 0);
Actions::addAction('say_hello', 'Sandbox\Demos\otherFunction', 1);
Actions::doAction('say_hello');

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