snappymail/rainloop/v/0.0.0/app/libraries/MailSo/Hooks.php

51 lines
878 B
PHP
Raw Normal View History

<?php
/*
* This file is part of MailSo.
*
* (c) 2014 Usenko Timur
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace MailSo;
/**
* @category MailSo
*/
class Hooks
{
/**
* @var array
*/
static $aCallbacks = array();
2020-03-16 20:08:53 +08:00
static public function Run(string $sName, array $aArg = array())
{
if (isset(\MailSo\Hooks::$aCallbacks[$sName]))
{
foreach (\MailSo\Hooks::$aCallbacks[$sName] as $mCallback)
{
\call_user_func_array($mCallback, $aArg);
}
}
}
/**
* @param mixed $mCallback
*/
2020-03-16 20:08:53 +08:00
static public function Add(string $sName, $mCallback)
{
if (\is_callable($mCallback))
{
if (!isset(\MailSo\Hooks::$aCallbacks[$sName]))
{
\MailSo\Hooks::$aCallbacks[$sName] = array();
}
\MailSo\Hooks::$aCallbacks[$sName][] = $mCallback;
}
}
}