PHP Classes

File: demos/filters_priority.php

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

Contents

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

use
Redbox\Hooks\Filters;

require
'autoload.php';

function
secondFunction($text = '')
{
    return
'@@' . $text;
}
Filters::addFilter('prepend_at', 'Sandbox\Demos\secondFunction', 1);

function
firstFunction($text = '')
{
    return
'!!' . $text;
}
Filters::addFilter('prepend_at', 'Sandbox\Demos\firstFunction', 0);

$out = Filters::applyFilter('prepend_at', 'This is a text');

/**
 * The result should be:
 *
 * Result: @@!!This is a text
 */
echo "Result: " . $out . "\n";