2017 © Pedro Peláez
 

library php-mediator

A class to provide hooks as actions and filters

image

montefuscolo/php-mediator

A class to provide hooks as actions and filters

  • Wednesday, May 16, 2018
  • by montefuscolo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

php-mediator Build Status

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)

Installing

composer require montefuscolo/php-mediator

Using it

Actions

<?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');

Filters

<?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

The Versions

16/05 2018

dev-master

9999999-dev

A class to provide hooks as actions and filters

  Sources   Download

LGPL-2.1

The Development Requires

by Fabio Montefuscolo

15/05 2018

1.0

1.0.0.0

A class to provide hooks as actions and filters

  Sources   Download

LGPL-2.1

The Development Requires

by Fabio Montefuscolo