PATH:
home
/
centosnipponia
/
public_html
/
ticketing.nipponia.com
/
ticketing-old
/
include
<?php /********************************************************************* class.signal.php Simple interface for a publish and subscribe signal model Jared Hancock <jared@osticket.com> Copyright (c) 2006-2013 osTicket http://www.osticket.com Released under the GNU General Public License WITHOUT ANY WARRANTY. See LICENSE.TXT for details. vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ /** * Signals implement a simple publish/subscribe event model. To keep things * simplistic between classes and to maintain compatible with PHP version 4, * signals will not be explicitly defined or registered. Instead, signals * are connected to callbacks via a string signal name. * * The system is proofed with a static inspection test which will ensure * that for every given Signal::connect() function call, somewhere else in * the codebase there exists a Signal::send() for the same named signal. */ class Signal { static private $subscribers = array(); /** * Subscribe to a signal. * * Signal::connect('user.auth', 'function'); * * The subscribed function should receive a two arguments and will have * this signature: * * function callback($object, $data); * * Where the $object argument is the object originating the signal, and * the $options is a hash-array of other information originating from- * and pertaining to the signal. * * The value of the $data argument is not defined. It is signal * specific. It should be a hash-array of data; however, no runtime * checks are made to ensure such an interface. * * Optionally, if $object is a class and is passed into the ::connect() * method, only instances of the named class or subclass will actually * be connected to the callable function. * * A predicate function, $check, can be used to filter calls to the * signal handler. The function will receive the signal data and should * return true if the signal handler should be called. */ static function connect($signal, $callable, $object=null, $check=null) { if (!isset(self::$subscribers[$signal])) self::$subscribers[$signal] = array(); // XXX: Ensure $object if set is a class if ($object && !is_string($object)) trigger_error(sprintf(_S("Invalid object: %s: Expected class"), $object)); elseif ($check && !is_callable($check)) { trigger_error(_S("Invalid check function: Must be callable")); $check = null; } self::$subscribers[$signal][] = array($object, $callable, $check); } /** * Publish a signal. * * Signal::send('user.login', $this, array('username'=>'blah')); * * All subscribers to the signal will be called in the order they * connect()ed to the signal. Subscribers do not have the opportunity to * interrupt or discontinue delivery of the signal to other subscribers. * The $object argument is required and should almost always be ($this). * Its interpretation is the object originating or sending the signal. * It could also be interpreted as the context of the signal. * * $data if sent should be a hash-array of data included with the signal * event. There is otherwise no definition for what should or could be * included in the $data array. The received data is received by * reference and can be passed to the callable by reference if the * callable is defined to receive it by reference. Therefore, it is * possible to propogate changes in the signal handlers back to the * originating context. */ static function send($signal, $object, &$data=null) { if (!isset(self::$subscribers[$signal])) return; foreach (self::$subscribers[$signal] as $sub) { list($s, $callable, $check) = $sub; if ($s && !is_a($object, $s)) continue; elseif ($check && !call_user_func_array($check, array($object, $data))) continue; call_user_func_array($callable, array($object, &$data)); } } } ?>
[+]
..
[-] .MANIFEST
[edit]
[-] ajax.admin.php
[edit]
[-] ajax.config.php
[edit]
[-] ajax.content.php
[edit]
[-] ajax.draft.php
[edit]
[-] ajax.email.php
[edit]
[-] ajax.export.php
[edit]
[-] ajax.filter.php
[edit]
[-] ajax.forms.php
[edit]
[-] ajax.i18n.php
[edit]
[-] ajax.kbase.php
[edit]
[-] ajax.note.php
[edit]
[-] ajax.orgs.php
[edit]
[-] ajax.plugins.php
[edit]
[-] ajax.schedule.php
[edit]
[-] ajax.search.php
[edit]
[-] ajax.sequence.php
[edit]
[-] ajax.staff.php
[edit]
[-] ajax.tasks.php
[edit]
[-] ajax.thread.php
[edit]
[-] ajax.tickets.php
[edit]
[-] ajax.tips.php
[edit]
[-] ajax.upgrader.php
[edit]
[-] ajax.users.php
[edit]
[-] api.cron.php
[edit]
[-] api.tickets.php
[edit]
[-] class.2fa.php
[edit]
[-] class.ajax.php
[edit]
[-] class.api.php
[edit]
[-] class.app.php
[edit]
[-] class.attachment.php
[edit]
[-] class.auth.php
[edit]
[-] class.avatar.php
[edit]
[-] class.banlist.php
[edit]
[-] class.base32.php
[edit]
[-] class.businesshours.php
[edit]
[-] class.canned.php
[edit]
[-] class.captcha.php
[edit]
[-] class.category.php
[edit]
[-] class.charset.php
[edit]
[-] class.cli.php
[edit]
[-] class.client.php
[edit]
[-] class.collaborator.php
[edit]
[-] class.company.php
[edit]
[-] class.config.php
[edit]
[-] class.controller.php
[edit]
[-] class.cron.php
[edit]
[-] class.crypto.php
[edit]
[-] class.csrf.php
[edit]
[-] class.dept.php
[edit]
[-] class.dispatcher.php
[edit]
[-] class.draft.php
[edit]
[-] class.dynamic_forms.php
[edit]
[-] class.email.php
[edit]
[-] class.error.php
[edit]
[-] class.export.php
[edit]
[-] class.faq.php
[edit]
[-] class.file.php
[edit]
[-] class.filter.php
[edit]
[-] class.filter_action.php
[edit]
[-] class.format.php
[edit]
[-] class.forms.php
[edit]
[-] class.http.php
[edit]
[-] class.i18n.php
[edit]
[-] class.import.php
[edit]
[-] class.json.php
[edit]
[-] class.knowledgebase.php
[edit]
[-] class.list.php
[edit]
[-] class.lock.php
[edit]
[-] class.log.php
[edit]
[-] class.mail.php
[edit]
[-] class.mailer.php
[edit]
[-] class.mailfetch.php
[edit]
[-] class.mailparse.php
[edit]
[-] class.message.php
[edit]
[-] class.migrater.php
[edit]
[-] class.mime.php
[edit]
[-] class.misc.php
[edit]
[-] class.model.php
[edit]
[-] class.nav.php
[edit]
[-] class.note.php
[edit]
[-] class.oauth2.php
[edit]
[-] class.organization.php
[edit]
[-] class.orm.php
[edit]
[-] class.osticket.php
[edit]
[-] class.ostsession.php
[edit]
[-] class.page.php
[edit]
[-] class.pagenate.php
[edit]
[-] class.passwd.php
[edit]
[-] class.pdf.php
[edit]
[-] class.plugin.php
[edit]
[-] class.priority.php
[edit]
[-] class.queue.php
[edit]
[-] class.report.php
[edit]
[-] class.role.php
[edit]
[-] class.schedule.php
[edit]
[-] class.search.php
[edit]
[-] class.sequence.php
[edit]
[-] class.session.php
[edit]
[-] class.setup.php
[edit]
[-] class.signal.php
[edit]
[-] class.sla.php
[edit]
[-] class.staff.php
[edit]
[-] class.task.php
[edit]
[-] class.team.php
[edit]
[-] class.template.php
[edit]
[-] class.thread.php
[edit]
[-] class.thread_actions.php
[edit]
[-] class.ticket.php
[edit]
[-] class.timezone.php
[edit]
[-] class.topic.php
[edit]
[-] class.translation.php
[edit]
[-] class.upgrader.php
[edit]
[-] class.user.php
[edit]
[-] class.usersession.php
[edit]
[-] class.util.php
[edit]
[-] class.validator.php
[edit]
[-] class.variable.php
[edit]
[-] class.xml.php
[edit]
[-] class.yaml.php
[edit]
[+]
cli
[+]
client
[+]
config
[+]
fpdf
[-] html2text.php
[edit]
[-] htmLawed.php
[edit]
[+]
i18n
[-] index.php
[edit]
[-] JSON.php
[edit]
[+]
laminas-mail
[+]
mpdf
[-] mysqli.php
[edit]
[-] ost-sampleconfig.php
[edit]
[-] PasswordHash.php
[edit]
[+]
pear
[+]
plugins
[-] Spyc.php
[edit]
[+]
staff
[-] tnef_decoder.php
[edit]
[-] UniversalClassLoader.php
[edit]
[+]
upgrader
[-] ost-config.php
[edit]
[-] .htaccess.disabled
[edit]