diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-07-08 16:45:19 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-07-08 16:45:19 +0200 |
commit | 925d09cb0e3aed2ab89a11d636111ba699cc403f (patch) | |
tree | 9f1288fbbbb74261840e1d58b8e30dcb605bb22b /lib/hooks | |
parent | 8d8f99fbc49b2747895743dc55d9ddf8c3aa842a (diff) | |
download | nextcloud-server-925d09cb0e3aed2ab89a11d636111ba699cc403f.tar.gz nextcloud-server-925d09cb0e3aed2ab89a11d636111ba699cc403f.zip |
add forwarding emitter for agregating multiple emitters
Diffstat (limited to 'lib/hooks')
-rw-r--r-- | lib/hooks/forwardingemitter.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/hooks/forwardingemitter.php b/lib/hooks/forwardingemitter.php new file mode 100644 index 00000000000..518641ac7cf --- /dev/null +++ b/lib/hooks/forwardingemitter.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Hooks; + +/** + * Class ForwardingEmitter + * + * allows forwarding all listen calls to other emitters + * + * @package OC\Hooks + */ +abstract class ForwardingEmitter extends BasicEmitter { + /** + * @var \OC\Hooks\Emitter[] array + */ + private $forwardEmitters = array(); + + /** + * @param string $scope + * @param string $method + * @param callable $callback + */ + public function listen($scope, $method, $callback) { + parent::listen($scope, $method, $callback); + foreach ($this->forwardEmitters as $emitter) { + $emitter->listen($scope, $method, $callback); + } + } + + /** + * @param \OC\Hooks\Emitter $emitter + */ + protected function forward($emitter) { + $this->forwardEmitters[] = $emitter; + } +} |