From 588727c7e2b8954ec3dbde293cf4c4d68b119f9b Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 19 Jun 2006 18:38:29 +0000 Subject: Merge from 3.0 branch till 1185. --- .../PhpDocumentor/phpDocumentor/Publisher.inc | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 buildscripts/PhpDocumentor/phpDocumentor/Publisher.inc (limited to 'buildscripts/PhpDocumentor/phpDocumentor/Publisher.inc') diff --git a/buildscripts/PhpDocumentor/phpDocumentor/Publisher.inc b/buildscripts/PhpDocumentor/phpDocumentor/Publisher.inc new file mode 100644 index 00000000..7e038021 --- /dev/null +++ b/buildscripts/PhpDocumentor/phpDocumentor/Publisher.inc @@ -0,0 +1,84 @@ + + * @author Joshua Eichorn + * @version $Id: Publisher.inc,v 1.1 2005/10/17 18:36:57 jeichorn Exp $ + * @package phpDocumentor + */ +/** + * a class for handling the publishing of data + * + * @author Kellin + * @author Joshua Eichorn + * @version $Id: Publisher.inc,v 1.1 2005/10/17 18:36:57 jeichorn Exp $ + * @package phpDocumentor + */ +class Publisher +{ + /**#@+ + * @var array + */ + /** + * Array of references objects that have Subscribed to this publisher + */ + var $subscriber = array(); + + var $tokens = array(); + + var $pushEvent = array(); + var $popEvent = array(); + /**#@-*/ + + + /** + * Adds a subscriber to the {@link $subscriber} array(). + * if $event is '*', the publisher will use $object as the default event handler + * @param integer $event see {@link Parser.inc} PARSER_EVENT_* constants + * @param class $object any class that has a HandleEvent() method like {@link phpDocumentor_IntermediateParser::HandleEvent()} or {@link Classes::HandleEvent()} + */ + function subscribe($event, &$object) + { + $this->subscriber[$event] =& $object; + } + + /** + * @param integer $event see {@link Parser.inc} PARSER_EVENT_* constants + * @param mixed $data anything the subscribed event handler is expecting + */ + function publishEvent($event,$data) + { + + // see if there is a specific event handler + if (!empty($this->subscriber[$event])) + { + $this->subscriber[$event]->HandleEvent($event,$data); + } + else if (isset($this->subscriber['*']) && is_object($this->subscriber['*'])) // check to see if a generic handler exists + { + $this->subscriber['*']->HandleEvent($event,$data); + } + } +} +?> -- cgit v1.2.3