dev-master
9999999-devA class to provide hooks as actions and filters
LGPL-2.1
The Development Requires
by Fabio Montefuscolo
1.0
1.0.0.0A class to provide hooks as actions and filters
LGPL-2.1
The Development Requires
by Fabio Montefuscolo
Wallogit.com
2017 © Pedro Peláez
A class to provide hooks as actions and filters
It is just another Hook system. It is useful to integrate very distinct components of software without making them too coupled to each other., (*1)
composer require montefuscolo/php-mediator
<?php
use montefuscolo/BaseMediator;
$mediator = new BaseMediator();
// Add callbacks to be called later
$mediator->add_action('my-channel', function() {
echo 'Hello World' . PHP_EOL;
});
$mediator->add_action('my-channel', function() {
echo 'Foo Bar' . PHP_EOL;
});
// ....
$mediator->run_actions('my-channel');
<?php
use montefuscolo/BaseMediator;
$mediator = new BaseMediator();
// Add callbacks to be called later
$mediator->add_filter('my-channel', function($n) {
return $n * 2;
});
$mediator->add_filter('my-channel', function($n) {
return $n * 3;
});
$mediator->add_filter('my-channel', function($n) {
return $n - 6;
});
// ....
echo $mediator->run_filters('my-channel', 1);
// >>> 0
A class to provide hooks as actions and filters
LGPL-2.1
A class to provide hooks as actions and filters
LGPL-2.1