pax_global_header00006660000000000000000000000064125100105530014502gustar00rootroot0000000000000052 comment=8049e0fc7abb48178b4a2a9af230eceebe1a83bc Events-2.4.0/000077500000000000000000000000001251001055300127515ustar00rootroot00000000000000Events-2.4.0/README.md000066400000000000000000000020671251001055300142350ustar00rootroot00000000000000Kdyby/Events ====== [![Build Status](https://travis-ci.org/Kdyby/Events.svg?branch=master)](https://travis-ci.org/Kdyby/Events) [![Downloads this Month](https://img.shields.io/packagist/dm/kdyby/events.svg)](https://packagist.org/packages/kdyby/events) [![Latest stable](https://img.shields.io/packagist/v/kdyby/events.svg)](https://packagist.org/packages/kdyby/events) Requirements ------------ Kdyby/Events requires PHP 5.3.2 or higher. - [Nette Framework](https://github.com/nette/nette) Kdyby/Events are also compatible with events dispatcher in [doctrine/common](https://github.com/doctrine/common), so you can use them with Doctrine. Installation ------------ The best way to install Kdyby/Events is using [Composer](http://getcomposer.org/): ```sh $ composer require kdyby/events:~2.2 ``` Documentation ------------ Learn more in the [documentation](https://github.com/Kdyby/Events/blob/master/docs/en/index.md). ----- Homepage [http://www.kdyby.org](http://www.kdyby.org) and repository [http://github.com/kdyby/events](http://github.com/kdyby/events). Events-2.4.0/composer.json000066400000000000000000000030761251001055300155010ustar00rootroot00000000000000{ "name": "kdyby/events", "type": "library", "description": "Events for Nette Framework", "keywords": ["nette", "kdyby"], "homepage": "http://kdyby.org", "license": ["BSD-3-Clause", "GPL-2.0", "GPL-3.0"], "authors": [ { "name": "Filip Procházka", "homepage": "http://filip-prochazka.com", "email": "filip@prochazka.su" } ], "support": { "email": "filip@prochazka.su", "issues": "https://github.com/kdyby/events/issues" }, "require": { "nette/di": "~2.3@dev", "nette/utils": "~2.3@dev" }, "require-dev": { "nette/nette": "~2.3@dev", "nette/application": "~2.3@dev", "nette/bootstrap": "~2.3@dev", "nette/caching": "~2.3@dev", "nette/component-model": "~2.2@dev", "nette/database": "~2.3@dev", "nette/deprecated": "~2.3@dev", "nette/di": "~2.3@dev", "nette/finder": "~2.3@dev", "nette/forms": "~2.3@dev", "nette/http": "~2.3@dev", "nette/mail": "~2.3@dev", "nette/neon": "~2.3@dev", "nette/php-generator": "~2.3@dev", "nette/reflection": "~2.3@dev", "nette/robot-loader": "~2.3@dev", "nette/safe-stream": "~2.3@dev", "nette/security": "~2.3@dev", "nette/tokenizer": "~2.2@dev", "latte/latte": "~2.3@dev", "tracy/tracy": "~2.3@dev", "nette/utils": "~2.3@dev", "symfony/event-dispatcher": "~2.5", "nette/tester": "~1.4@rc", "jakub-onderka/php-parallel-lint": "~0.7" }, "autoload": { "psr-0": { "Kdyby\\Events\\": "src/" }, "classmap": [ "src/Kdyby/Events/exceptions.php" ], "files": [ "src/Doctrine/compatibility.php" ] }, "extra": { "branch-alias": { "dev-master": "2.4-dev" } } } Events-2.4.0/license.md000066400000000000000000000045361251001055300147250ustar00rootroot00000000000000Licenses ======== Good news! You may use Kdyby Framework under the terms of either the New BSD License or the GNU General Public License (GPL) version 2 or 3. The BSD License is recommended for most projects. It is easy to understand and it places almost no restrictions on what you can do with the framework. If the GPL fits better to your project, you can use the framework under this license. You don't have to notify anyone which license you are using. You can freely use Kdyby Framework in commercial projects as long as the copyright header remains intact. New BSD License --------------- Copyright (c) 2008 Filip Procházka (http://filip-prochazka.com) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of "Kdyby Framework" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. GNU General Public License -------------------------- GPL licenses are very very long, so instead of including them here we offer you URLs with full text: - [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html) - [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html) Events-2.4.0/src/000077500000000000000000000000001251001055300135405ustar00rootroot00000000000000Events-2.4.0/src/Doctrine/000077500000000000000000000000001251001055300153075ustar00rootroot00000000000000Events-2.4.0/src/Doctrine/compatibility.php000066400000000000000000000020141251001055300206660ustar00rootroot00000000000000addEventListener(\$subscriber->getSubscribedEvents(), \$subscriber); } public function removeEventSubscriber(EventSubscriber \$subscriber) { \$this->removeEventListener(\$subscriber->getSubscribedEvents(), \$subscriber); } abstract public function addEventListener(\$events, \$listener); abstract public function removeEventListener(\$events, \$listener = NULL); } interface EventSubscriber { function getSubscribedEvents(); } } GEN; eval($aliases); define('KDYBY_TO_DOCTRINE_EVENTS', 1); } Events-2.4.0/src/Kdyby/000077500000000000000000000000001251001055300146225ustar00rootroot00000000000000Events-2.4.0/src/Kdyby/Events/000077500000000000000000000000001251001055300160665ustar00rootroot00000000000000Events-2.4.0/src/Kdyby/Events/DI/000077500000000000000000000000001251001055300163625ustar00rootroot00000000000000Events-2.4.0/src/Kdyby/Events/DI/EventsExtension.php000066400000000000000000000273001251001055300222360ustar00rootroot00000000000000 */ class EventsExtension extends Nette\DI\CompilerExtension { /** @deprecated */ const EVENT_TAG = self::TAG_EVENT; /** @deprecated */ const SUBSCRIBER_TAG = self::TAG_SUBSCRIBER; const TAG_EVENT = 'kdyby.event'; const TAG_SUBSCRIBER = 'kdyby.subscriber'; const PANEL_COUNT_MODE = 'count'; /** * @var array */ public $defaults = array( 'subscribers' => array(), 'validate' => TRUE, 'autowire' => TRUE, 'optimize' => TRUE, 'debugger' => '%debugMode%', 'exceptionHandler' => NULL, ); /** * @var array */ private $listeners = array(); /** * @var array */ private $allowedManagerSetup = array(); public function loadConfiguration() { $this->listeners = array(); $this->allowedManagerSetup = array(); $builder = $this->getContainerBuilder(); $config = $this->getConfig($this->defaults); $userConfig = $this->getConfig(); if (!isset($userConfig['debugger']) && !$config['debugger']) { $config['debugger'] = self::PANEL_COUNT_MODE; } $evm = $builder->addDefinition($this->prefix('manager')) ->setClass('Kdyby\Events\EventManager') ->setInject(FALSE); if ($config['debugger']) { $defaults = array('dispatchTree' => FALSE, 'dispatchLog' => TRUE, 'events' => TRUE, 'listeners' => FALSE); if (is_array($config['debugger'])) { $config['debugger'] = Nette\DI\Config\Helpers::merge($config['debugger'], $defaults); } else { $config['debugger'] = $config['debugger'] !== self::PANEL_COUNT_MODE; } $evm->addSetup('Kdyby\Events\Diagnostics\Panel::register(?, ?)->renderPanel = ?', array('@self', '@container', $config['debugger'])); } if ($config['exceptionHandler'] !== NULL) { $evm->addSetup('setExceptionHandler', $this->filterArgs($config['exceptionHandler'])); } Nette\Utils\Validators::assertField($config, 'subscribers', 'array'); foreach ($config['subscribers'] as $subscriber) { $def = $builder->addDefinition($this->prefix('subscriber.' . md5(Nette\Utils\Json::encode($subscriber)))); list($def->factory) = Nette\DI\Compiler::filterArguments(array( is_string($subscriber) ? new Nette\DI\Statement($subscriber) : $subscriber )); list($subscriberClass) = (array) $builder->normalizeEntity($def->factory->entity); if (class_exists($subscriberClass)) { $def->class = $subscriberClass; } $def->setAutowired(FALSE); $def->addTag(self::SUBSCRIBER_TAG); } if (class_exists('Symfony\Component\EventDispatcher\Event')) { $builder->addDefinition($this->prefix('symfonyProxy')) ->setClass('Symfony\Component\EventDispatcher\EventDispatcherInterface') ->setFactory('Kdyby\Events\SymfonyDispatcher'); } } public function beforeCompile() { $builder = $this->getContainerBuilder(); $config = $this->getConfig($this->defaults); $manager = $builder->getDefinition($this->prefix('manager')); foreach (array_keys($builder->findByTag(self::SUBSCRIBER_TAG)) as $serviceName) { $manager->addSetup('addEventSubscriber', array('@' . $serviceName)); } Nette\Utils\Validators::assertField($config, 'validate', 'bool'); if ($config['validate']) { $this->validateSubscribers($builder, $manager); } Nette\Utils\Validators::assertField($config, 'autowire', 'bool'); if ($config['autowire']) { $this->autowireEvents($builder); } Nette\Utils\Validators::assertField($config, 'optimize', 'bool'); if ($config['optimize']) { if (!$config['validate']) { throw new Kdyby\Events\InvalidStateException("Cannot optimize without validation."); } $this->optimizeListeners($builder); } } public function afterCompile(Code\ClassType $class) { $init = $class->methods['initialize']; /** @hack This tries to add the event invokation right after the code, generated by NetteExtension. */ $foundNetteInitStart = $foundNetteInitEnd = FALSE; $lines = explode(";\n", trim($init->body)); $init->body = NULL; while (($line = array_shift($lines)) || $lines) { if ($foundNetteInitStart && !$foundNetteInitEnd && stripos($line, 'Nette\\') === FALSE && stripos($line, 'set_include_path') === FALSE && stripos($line, 'date_default_timezone_set') === FALSE ) { $init->addBody(Code\Helpers::format( '$this->getService(?)->createEvent(?)->dispatch($this);', $this->prefix('manager'), array('Nette\\DI\\Container', 'onInitialize') )); $foundNetteInitEnd = TRUE; } if (!$foundNetteInitEnd && ( stripos($line, 'Nette\\') !== FALSE || stripos($line, 'set_include_path') !== FALSE || stripos($line, 'date_default_timezone_set') !== FALSE )) { $foundNetteInitStart = TRUE; } $init->addBody($line . ';'); } if (!$foundNetteInitEnd) { $init->addBody(Code\Helpers::format( '$this->getService(?)->createEvent(?)->dispatch($this);', $this->prefix('manager'), array('Nette\\DI\\Container', 'onInitialize') )); } } /** * @param \Nette\DI\ContainerBuilder $builder * @param \Nette\DI\ServiceDefinition $manager * @throws AssertionException */ private function validateSubscribers(Nette\DI\ContainerBuilder $builder, Nette\DI\ServiceDefinition $manager) { foreach ($manager->setup as $stt) { if ($stt->entity !== 'addEventSubscriber') { $this->allowedManagerSetup[] = $stt; continue; } try { $serviceName = $builder->getServiceName(reset($stt->arguments)); $def = $builder->getDefinition($serviceName); } catch (\Exception $e) { throw new AssertionException( "Please, do not register listeners directly to service '" . $this->prefix('manager') . "'. " . "Use section '" . $this->name . ": subscribers: ', or tag the service as '" . self::SUBSCRIBER_TAG . "'.", 0, $e ); } if (!$def->class) { throw new AssertionException( "Please, specify existing class for " . (is_numeric($serviceName) ? 'anonymous ' : '') . "service '$serviceName' explicitly, " . "and make sure, that the class exists and can be autoloaded." ); } elseif (!class_exists($def->class)) { throw new AssertionException( "Class '{$def->class}' of " . (is_numeric($serviceName) ? 'anonymous ' : '') . "service '$serviceName' cannot be found. " . "Please make sure, that the class exists and can be autoloaded." ); } if (!in_array('Doctrine\Common\EventSubscriber' , class_implements($def->class))) { // the minimum is Doctrine EventSubscriber, but recommend is Kdyby Subscriber throw new AssertionException("Subscriber '$serviceName' doesn't implement Kdyby\\Events\\Subscriber."); } $eventNames = array(); $listenerInst = self::createInstanceWithoutConstructor($def->class); foreach ($listenerInst->getSubscribedEvents() as $eventName => $params) { if (is_numeric($eventName) && is_string($params)) { // [EventName, ...] list(, $method) = Kdyby\Events\Event::parseName($params); $eventNames[] = ltrim($params, '\\'); if (!method_exists($listenerInst, $method)) { throw new AssertionException("Event listener " . $def->class . "::{$method}() is not implemented."); } } elseif (is_string($eventName)) { // [EventName => ???, ...] $eventNames[] = ltrim($eventName, '\\'); if (is_string($params)) { // [EventName => method, ...] if (!method_exists($listenerInst, $params)) { throw new AssertionException("Event listener " . $def->class . "::{$params}() is not implemented."); } } elseif (is_string($params[0])) { // [EventName => [method, priority], ...] if (!method_exists($listenerInst, $params[0])) { throw new AssertionException("Event listener " . $def->class . "::{$params[0]}() is not implemented."); } } else { foreach ($params as $listener) { // [EventName => [[method, priority], ...], ...] if (!method_exists($listenerInst, $listener[0])) { throw new AssertionException("Event listener " . $def->class . "::{$listener[0]}() is not implemented."); } } } } } $this->listeners[$serviceName] = array_unique($eventNames); } } /** * @param \Nette\DI\ContainerBuilder $builder */ private function autowireEvents(Nette\DI\ContainerBuilder $builder) { foreach ($builder->getDefinitions() as $def) { /** @var Nette\DI\ServiceDefinition $def */ if ($def->factory instanceof Nette\DI\Statement && $def->factory->entity instanceof Nette\DI\ServiceDefinition) { continue; // alias } if (!class_exists($class = $builder->expand($def->class))) { if (!$def->factory) { continue; } elseif (is_array($class = $builder->expand($def->factory->entity))) { continue; } elseif (!class_exists($class)) { continue; } } $this->bindEventProperties($def, Nette\Reflection\ClassType::from($class)); } } protected function bindEventProperties(Nette\DI\ServiceDefinition $def, Nette\Reflection\ClassType $class) { foreach ($class->getProperties(Nette\Reflection\Property::IS_PUBLIC) as $property) { if (!preg_match('#^on[A-Z]#', $name = $property->getName())) { continue; } if ($property->hasAnnotation('persistent') || $property->hasAnnotation('inject')) { // definitely not an event continue; } $def->addSetup('$' . $name, array( new Nette\DI\Statement($this->prefix('@manager') . '::createEvent', array( array($class->getName(), $name), new Code\PhpLiteral('$service->' . $name) )) )); } } /** * @param \Nette\DI\ContainerBuilder $builder */ private function optimizeListeners(Nette\DI\ContainerBuilder $builder) { $listeners = array(); foreach ($this->listeners as $serviceName => $eventNames) { foreach ($eventNames as $eventName) { list($namespace, $event) = Kdyby\Events\Event::parseName($eventName); $listeners[$eventName][] = $serviceName; if (!$namespace || !class_exists($namespace)) { continue; // it might not even be a "classname" event namespace } // find all subclasses and register the listener to all the classes dispatching them foreach ($builder->getDefinitions() as $def) { if (!$class = $def->getClass()) { continue; // ignore unresolved classes } if (is_subclass_of($class, $namespace)) { $listeners["$class::$event"][] = $serviceName; } } } } foreach ($listeners as $id => $subscribers) { $listeners[$id] = array_unique($subscribers); } $builder->getDefinition($this->prefix('manager')) ->setClass('Kdyby\Events\LazyEventManager', array($listeners)) ->setup = $this->allowedManagerSetup; } /** * @param string|\stdClass $statement * @return Nette\DI\Statement[] */ private function filterArgs($statement) { return Nette\DI\Compiler::filterArguments(array(is_string($statement) ? new Nette\DI\Statement($statement) : $statement)); } /** * @param \Nette\Configurator $configurator */ public static function register(Nette\Configurator $configurator) { $configurator->onCompile[] = function ($config, Nette\DI\Compiler $compiler) { $compiler->addExtension('events', new EventsExtension()); }; } /** * @param string $class * @return \Doctrine\Common\EventSubscriber */ private static function createInstanceWithoutConstructor($class) { if (method_exists('ReflectionClass', 'newInstanceWithoutConstructor')) { $listenerInst = Nette\Reflection\ClassType::from($class)->newInstanceWithoutConstructor(); } else { $listenerInst = unserialize(sprintf('O:%d:"%s":0:{}', strlen($class), $class)); } return $listenerInst; } } Events-2.4.0/src/Kdyby/Events/Diagnostics/000077500000000000000000000000001251001055300203355ustar00rootroot00000000000000Events-2.4.0/src/Kdyby/Events/Diagnostics/Panel.php000066400000000000000000000312361251001055300221120ustar00rootroot00000000000000 */ class Panel extends Nette\Object implements Tracy\IBarPanel { /** * @var EventManager */ private $evm; /** * @var Nette\DI\Container */ private $sl; /** * @var array */ private $events = array(); /** * @var array */ private $dispatchLog = array(); /** * @var array */ private $dispatchTree = array(); /** * @var array|NULL */ private $dispatchTreePointer = NULL; /** * @var array */ private $listenerIds = array(); /** * @var array */ private $inlineCallbacks = array(); /** * @var array */ private $registeredClasses; /** * @var bool */ public $renderPanel = TRUE; public function __construct(Nette\DI\Container $sl) { $this->sl = $sl; } /** * @param EventManager $evm */ public function setEventManager(EventManager $evm) { $this->evm = $evm; $evm->setPanel($this); } public function setServiceIds(array $listenerIds) { if (!$this->renderPanel || (is_array($this->renderPanel) && !$this->renderPanel['listeners'])) { return; } $this->listenerIds = $listenerIds; } public function registerEvent(Event $event) { $this->events[] = $event; $event->setPanel($this); } public function eventDispatch($eventName, EventArgs $args = NULL) { if (!$this->renderPanel) { return; } if (!is_array($this->renderPanel) || $this->renderPanel['dispatchLog']) { $this->dispatchLog[$eventName][] = $args; } if (!is_array($this->renderPanel) || $this->renderPanel['dispatchTree']) { // [parent-ref, name, args, children] $meta = array(&$this->dispatchTreePointer, $eventName, $args, array()); if ($this->dispatchTreePointer === NULL) { $this->dispatchTree[] = & $meta; } else { $this->dispatchTreePointer[3][] = & $meta; } $this->dispatchTreePointer = & $meta; } } public function eventDispatched($eventName, EventArgs $args = NULL) { if (!$this->renderPanel || (is_array($this->renderPanel) && !$this->renderPanel['dispatchTree'])) { return; } $this->dispatchTreePointer = &$this->dispatchTreePointer[0]; } public function inlineCallbacks($eventName, $inlineCallbacks) { if (!$this->renderPanel) { return; } $this->inlineCallbacks[$eventName] = (array) $inlineCallbacks; } /** * Renders HTML code for custom tab. * * @return string */ public function getTab() { if (empty($this->events)) { return NULL; } return '' . '' . count(Arrays::flatten($this->dispatchLog)) . ' calls' . ''; } /** * Renders HTML code for custom panel. * * @return string */ public function getPanel() { if (!$this->renderPanel) { return ''; } if (empty($this->events)) { return NULL; } $visited = array(); $h = 'htmlspecialchars'; $s = ''; $s .= $this->renderPanelDispatchLog($visited); $s .= $this->renderPanelEvents($visited); $s .= $this->renderPanelListeners($visited); if ($s) { $s .= ' '; } $s .= $this->renderPanelDispatchTree(); $totalEvents = count($this->listenerIds); $totalListeners = count(array_unique(Arrays::flatten($this->listenerIds))); return ''. '

' . $h($totalEvents) . ' registered events, ' . $h($totalListeners) . ' registered listeners

' . '
' . $s . '
'; } private function renderPanelDispatchLog(&$visited) { if (!$this->renderPanel || (is_array($this->renderPanel) && !$this->renderPanel['dispatchLog'])) { return ''; } $h = 'htmlspecialchars'; $s = ''; foreach ($this->dispatchLog as $eventName => $calls) { $s .= '' . count($calls) . 'x ' . $h($eventName) . ''; $visited[] = $eventName; $s .= $this->renderListeners($this->getInlineCallbacks($eventName)); if (empty($this->listenerIds[$eventName])) { $s .= ' no system listeners'; } else { $s .= $this->renderListeners($this->listenerIds[$eventName]); } $s .= $this->renderCalls($calls); } return $s; } private function renderPanelEvents(&$visited) { if (!$this->renderPanel || (is_array($this->renderPanel) && !$this->renderPanel['events'])) { return ''; } $h = 'htmlspecialchars'; $s = ''; foreach ($this->events as $event) { /** @var Event $event */ if (in_array($event->getName(), $visited, TRUE)) { continue; } $calls = $this->getEventCalls($event->getName()); $s .= ' '; $s .= '' . count($calls) . 'x ' . $h($event->getName()) . ''; $visited[] = $event->getName(); $s .= $this->renderListeners($this->getInlineCallbacks($event->getName())); if (empty($this->listenerIds[$event->getName()])) { $s .= ' no system listeners'; } else { $s .= $this->renderListeners($this->listenerIds[$event->getName()]); } $s .= $this->renderCalls($calls); } return $s; } private function renderPanelListeners(&$visited) { if (!$this->renderPanel || (is_array($this->renderPanel) && !$this->renderPanel['listeners'])) { return ''; } $h = 'htmlspecialchars'; $s = ''; foreach ($this->listenerIds as $eventName => $ids) { if (in_array($eventName, $visited, TRUE)) { continue; } $calls = $this->getEventCalls($eventName); $s .= ' '; $s .= '' . count($calls) . 'x ' . $h($eventName) . ''; $s .= $this->renderListeners($this->getInlineCallbacks($eventName)); if (empty($ids)) { $s .= ' no system listeners'; } else { $s .= $this->renderListeners($ids); } $s .= $this->renderCalls($calls); } return $s; } private function renderPanelDispatchTree() { if (!$this->renderPanel || (is_array($this->renderPanel) && !$this->renderPanel['dispatchTree'])) { return ''; } $s = 'Summary event call graph'; foreach ($this->dispatchTree as $item) { $s .= ''; $s .= $this->renderTreeItem($item); $s .= ''; } return $s; } /** * Renders an item in call graph. * * @param array $item * @return string */ private function renderTreeItem(array $item) { $h = 'htmlspecialchars'; $s = ''; } private function getEventCalls($eventName) { return !empty($this->dispatchLog[$eventName]) ? $this->dispatchLog[$eventName] : array(); } private function getInlineCallbacks($eventName) { return !empty($this->inlineCallbacks[$eventName]) ? $this->inlineCallbacks[$eventName] : array(); } private function renderListeners($ids) { static $addIcon; if (empty($addIcon)) { $addIcon = ''; } $registeredClasses = $this->getClassMap(); $h = 'htmlspecialchars'; $shortFilename = function (Nette\Reflection\GlobalFunction $refl) { $title = '.../' . basename($refl->getFileName()) . ':' . $refl->getStartLine(); if ($editor = Tracy\Helpers::editorUri($refl->getFileName(), $refl->getStartLine())) { return sprintf(' defined at %s', htmlspecialchars($editor), $title); } return ' defined at ' . $title; }; $s = ''; foreach ($ids as $id) { if (is_callable($id)) { $s .= '' . $addIcon . '
' .
					Callback::toString($id) . ($id instanceof \Closure ? $shortFilename(Callback::toReflection($id)) : '') .
					'';

				continue;
			}

			if (!$this->sl->isCreated($id) && ($class = array_search($id, $registeredClasses, TRUE))) {
				$s .= '' . $addIcon . '
' .
					$h(Nette\Reflection\ClassType::from($class)->getName()) .
					'';

			} else {
				try {
					$s .= '' . $addIcon . '' . self::dumpToHtml($this->sl->getService($id)) . '';

				} catch (\Exception $e) {
					$s .= "Service $id cannot be loaded because of exception

\n" . (string) $e . ''; } } } return $s; } private static function dumpToHtml($structure) { return Dumper::toHtml($structure, array(Dumper::COLLAPSE => TRUE, Dumper::DEPTH => 2)); } private function getClassMap() { if ($this->registeredClasses !== NULL) { return $this->registeredClasses; } if (property_exists('Nette\DI\Container', 'classes')) { return $this->registeredClasses = $this->sl->classes; } $refl = new Nette\Reflection\Property('Nette\DI\Container', 'meta'); $refl->setAccessible(TRUE); $meta = $refl->getValue($this->sl); $this->registeredClasses = array(); foreach ($meta['types'] as $type => $serviceIds) { if (isset($this->registeredClasses[$type])) { $this->registeredClasses[$type] = FALSE; continue; } $this->registeredClasses[$type] = $serviceIds; } return $this->registeredClasses; } private function renderCalls(array $calls) { static $runIcon; if (empty($runIcon)) { $runIcon = ''; } $s = ''; foreach ($calls as $args) { $s .= '' . $runIcon . ''; $s .='' . self::dumpToHtml($args) : '>dispatched without arguments'); $s .= ''; } return $s; } /** * @param string * @return string */ private function formatEventId($name) { return 'kdyby-event-' . md5($name); } /** * @param object * @return string */ private function formatArgsId($args) { return 'kdyby-event-arg-' . md5(spl_object_hash($args)); } /** * @return string */ protected function renderStyles() { return <<setEventManager($eventManager); static::getDebuggerBar()->addPanel($panel); return $panel; } /** * @return Bar */ private static function getDebuggerBar() { return method_exists('Tracy\Debugger', 'getBar') ? Debugger::getBar() : Debugger::$bar; } } Events-2.4.0/src/Kdyby/Events/Diagnostics/add.png000066400000000000000000000013511251001055300215730ustar00rootroot00000000000000PNG  IHDR szz pHYs   cHRMz%u0`:o_FoIDATx엿ka?%^cKZB'.j&ũtA77A"讓CQKЭ % `C%{84A^)Y<>wC?g;mqbb"P @msRIG:_8,قW~,P=R:X\LO7K3W#@XxW&}#`G$XJs ؠhqf/1FGb/+983WRc@,㱚Ioۯv)H'zPv)=WݑDJw=b ;mvM kb% sHd%x:Wj{Gj`Fj)IDRA- .aH8N'F#f}(a(CH4CFY̝sxn>*°)A otuܟFŴamjVZ[_W?RF&{jӆhCS;V|HuOQ?)#Qsq'zXʏ_.[C$Wj;Φ(M qkvB N!IENDB`Events-2.4.0/src/Kdyby/Events/Diagnostics/icon.png000066400000000000000000000034751251001055300220040ustar00rootroot00000000000000PNG  IHDR szz pHYs   cHRMz%u0`:o_FIDATx]l\GskﮍqLĉ&i"үPZP/EH S"aJ)*dh@UԪRDĐ*!v$m?_k{g;uoJ^¬9wΜ?_'9,>Bw~% qQmoG{̿zxlpeYSP%ˢ`,sy֟zN6덿d(΂ߞC`=^; Wl^>W%5tc9!"mer\_z/޼go,?Jo>J0;9&Lx 岪5p-w?gohʦU&~zփogt!k}k~X, G9|>~oa3>Nm hnDv8q`o4J-;6< 4.W]ѢآXZ@AH4oCI1hc0H TD6Xc3>/DhFH  Q♵5Yn"w(/_Wx ?m;=ښ{pLnW@mPJ<:^(51@`#,Pu1긻7@zO-US[/"BH F I6!GZ1!|j*(Ů%](Gc(`0D9O\/uasl[vC޿8ISsaL@/@ (Q<Fؾh,V,s)j^Kya:h 0ϣ-=u8hr~Gw/o7 RD[i ?DYЋ]fL9m4 =Drd @ide$}b+kWĨZ. Ԯ.alF癚 (1#c(ʼnR.8r/@`jAТ\}DiELºp^KH}IGJLzbSC=/t7|qxI@_܇7!ou!Ez?\ͷK1@Ϋ ?WbSRٞF%  (ÙmvKo:#26Ȗ!S^JtJhÇ̉.ưȯpl2'±|00|Hiݐ_8BVl-V?}r8~,'ƐҒDaYW]p@k=n:LzHLj~U_mby.:8{4Varxel.@Ҥgr;7,ˬ=fV]ZCZ1 sQX[466T* e1˲TYv.Fj- #'|ř}(BycLz/L꒗RV{UTT1}jؙi8Pj!PJ) <]VV}׀d2>[fxho0o9#*-FGGźuDWUUeLwwill4|-Hy<_IENDB`Events-2.4.0/src/Kdyby/Events/Diagnostics/run.png000066400000000000000000000017461251001055300216570ustar00rootroot00000000000000PNG  IHDR szz pHYs   cHRMz%u0`:o_FlIDATxOU?}y<:`EyQX2Fbo1]v_3z13 Y%p1@iݺKi<?>zw2; %i"wz5MRs(6 |xWͳDn%yU XJ jIInP7[]x4sopb ce-~Qn!W{baw:3$ )vƂbw9X3~t5uhmkQ0@raաX]̅Wsysd7FTPchH!bSМn\ !r e$mM@c(LnSМK15 ؊_ί?s7"!`Eux\"u&Hx1yl0@qS#kwHJ~7Z1]0=,fKݣs!✞Q47@s‑U/w VI $[[5]~xr3:3hHIENDB`Events-2.4.0/src/Kdyby/Events/Event.php000066400000000000000000000130421251001055300176600ustar00rootroot00000000000000 */ class Event implements \ArrayAccess, \IteratorAggregate, \Countable { /** * @var callable[] */ private $listeners = array(); /** * @var string */ private $name; /** * @var string */ private $namespace; /** * @var EventManager */ private $eventManager; /** * @var string */ private $argsClass; /** * @var Diagnostics\Panel */ private $panel; /** * @param string|array $name * @param array $defaults * @param string $argsClass */ public function __construct($name, $defaults = array(), $argsClass = NULL) { list($this->namespace, $this->name) = self::parseName($name); $this->argsClass = $argsClass; if (is_array($defaults) || $defaults instanceof \Traversable) { foreach ($defaults as $listener) { $this->add($listener); } } } /** * @internal * @param Diagnostics\Panel $panel */ public function setPanel(Diagnostics\Panel $panel) { $this->panel = $panel; } /** * @return string */ public function getName() { return ($this->namespace ? $this->namespace . '::' : '') . $this->name; } /** * @param EventManager $eventManager * @return Event */ public function injectEventManager(EventManager $eventManager) { $this->eventManager = $eventManager; return $this; } /** * Invokes the event. * * @param array $args */ public function dispatch($args = array()) { if (!is_array($args)) { $args = func_get_args(); } foreach ($this->getListeners() as $handler) { if (Callback::invokeArgs($handler, array_values($args)) === FALSE) { return; } } } /** * @param callable $listener * @return Event */ public function append($listener) { Callback::check($listener, TRUE); $this->listeners[] = $listener; return $this; } /** * @param callable $listener * @return Event */ public function prepend($listener) { Callback::check($listener, TRUE); array_unshift($this->listeners, $listener); return $this; } /** * @return array|callable[] */ public function getListeners() { $listeners = $this->listeners; if ($this->panel) { $this->panel->inlineCallbacks($this->getName(), $listeners); } elseif (!$this->eventManager || !$this->eventManager->hasListeners($this->getName())) { return $listeners; } $name = $this->getName(); $evm = $this->eventManager; $argsClass = $this->argsClass; $listeners[] = function () use ($name, $evm, $argsClass) { if ($argsClass === NULL) { $args = new EventArgsList(func_get_args()); } else { $args = Nette\Reflection\ClassType::from($argsClass)->newInstanceArgs(func_get_args()); } $evm->dispatchEvent($name, $args); }; return $listeners; } /** * Invokes the event. */ public function __invoke() { $this->dispatch(func_get_args()); } /** * @param string $name * @return array */ public static function parseName(&$name) { if (is_array($name)) { return $name; } if (preg_match('~^([^\w]?(?P.*\w+)(?P[^\w]{1,2}))?(?P[a-z]\w+)$~i', $name, $m)) { $name = ($m['namespace'] ? $m['namespace'] . $m['separator'] : '') . $m['name']; return array($m['namespace'] ?: NULL, $m['name'], $m['separator'] ?: NULL); } else { $name = ltrim($name, '\\'); } return array(NULL, $name, NULL); } /** @deprecated */ public function add($listener) { return $this->append($listener); } /** @deprecated */ public function unshift($listener) { return $this->prepend($listener); } /********************* interface \Countable *********************/ /** * @return int */ public function count() { return count($this->listeners); } /********************* interface \IteratorAggregate *********************/ /** * @return \ArrayIterator|\Traversable */ public function getIterator() { return new \ArrayIterator($this->getListeners()); } /********************* interface \ArrayAccess *********************/ /** * @param int|NULL $index * @param callable $item */ public function offsetSet($index, $item) { Callback::check($item, TRUE); if ($index === NULL) { // append $this->listeners[] = $item; } else { // replace $this->listeners[$index] = $item; } } /** * @param mixed $index * @return callable * @throws OutOfRangeException */ public function offsetGet($index) { if (!$this->offsetExists($index)) { throw new OutOfRangeException; } return $this->listeners[$index]; } /** * @param int $index * * @return bool */ public function offsetExists($index) { return isset($this->listeners[$index]); } /** * @param int $index */ public function offsetUnset($index) { unset($this->listeners[$index]); } /********************* Simpler Nette\Object *********************/ /** * @param $name * @return mixed|void * @throws MemberAccessException */ public function &__get($name) { throw new MemberAccessException("There is no property $name in " . get_class($this)); } /** * @param $name * @param $value * @throws MemberAccessException */ public function __set($name, $value) { throw new MemberAccessException("There is no property $name in " . get_class($this)); } } Events-2.4.0/src/Kdyby/Events/EventArgs.php000066400000000000000000000007031251001055300204750ustar00rootroot00000000000000 */ abstract class EventArgs extends Doctrine\Common\EventArgs { } Events-2.4.0/src/Kdyby/Events/EventArgsList.php000066400000000000000000000012131251001055300213260ustar00rootroot00000000000000 */ class EventArgsList extends EventArgs { /** * @var array */ private $args; /** * @param array $args */ public function __construct(array $args) { $this->args = $args; } /** * @return array */ public function getArgs() { return $this->args; } } Events-2.4.0/src/Kdyby/Events/EventManager.php000066400000000000000000000253141251001055300211600ustar00rootroot00000000000000 */ class EventManager extends Doctrine\Common\EventManager { /** * [Event => [Priority => [[Listener, method], Subscriber, Subscriber, ...]]] * * @var array[] */ private $listeners = array(); /** * [Event => [Subscriber, Subscriber, [callable], ...]] * * @var array[] */ private $sorted = array(); /** * [SubscriberHash => Subscriber] * * @var array[] */ private $subscribers = array(); /** * @var Diagnostics\Panel */ private $panel; /** * @var IExceptionHandler */ private $exceptionHandler; /** * @internal * @param Diagnostics\Panel $panel */ public function setPanel(Diagnostics\Panel $panel) { $this->panel = $panel; } /** * @param IExceptionHandler $exceptionHandler */ public function setExceptionHandler(IExceptionHandler $exceptionHandler) { $this->exceptionHandler = $exceptionHandler; } /** * Dispatches an event to all registered listeners. * * @param string $eventName The name of the event to dispatch. The name of the event is the name of the method that is invoked on listeners. * @param Doctrine\Common\EventArgs $eventArgs The event arguments to pass to the event handlers/listeners. If not supplied, the single empty EventArgs instance is used */ public function dispatchEvent($eventName, Doctrine\Common\EventArgs $eventArgs = NULL) { if ($this->panel) { $this->panel->eventDispatch($eventName, $eventArgs); } list($namespace, $event) = Event::parseName($eventName); foreach ($this->getListeners($eventName) as $listener) { try { if ($listener instanceof EventSubscriber) { $listener = array($listener, $event); } if ($eventArgs instanceof EventArgsList) { /** @var EventArgsList $eventArgs */ call_user_func_array($listener, $eventArgs->getArgs()); } else { call_user_func($listener, $eventArgs); } } catch (\Exception $e) { if ($this->exceptionHandler) { $this->exceptionHandler->handleException($e); } else { throw $e; } } } if ($this->panel) { $this->panel->eventDispatched($eventName, $eventArgs); } } /** * Gets the listeners of a specific event or all listeners. * * @param string $eventName * @return Doctrine\Common\EventSubscriber[]|callable[] */ public function getListeners($eventName = NULL) { if ($eventName !== NULL) { if (!isset($this->sorted[$eventName])) { $this->sortListeners($eventName); } return $this->sorted[$eventName]; } foreach ($this->listeners as $event => $prioritized) { if (!isset($this->sorted[$event])) { $this->sortListeners($event); } } return array_filter($this->sorted); } /** * Checks whether an event has any registered listeners. * * @param string $eventName * @return boolean TRUE if the specified event has any listeners, FALSE otherwise. */ public function hasListeners($eventName) { return (bool) count($this->getListeners($eventName)); } /** * Adds an event listener that listens on the specified events. * * @param string|array $events The event(s) to listen on. * @param Doctrine\Common\EventSubscriber|array $subscriber The listener object. * @param int $priority * * @throws InvalidListenerException */ public function addEventListener($events, $subscriber, $priority = 0) { foreach ((array) $events as $eventName) { list($namespace, $event) = Event::parseName($eventName); $callback = !is_array($subscriber) ? array($subscriber, $event) : $subscriber; if (!method_exists($callback[0], $callback[1])) { throw new InvalidListenerException("Event listener '" . get_class($callback[0]) . "' has no method '" . $callback[1] . "'"); } $this->listeners[$eventName][$priority][] = $subscriber; unset($this->sorted[$eventName]); } } /** * Removes an event listener from the specified events. * * @param string|array $unsubscribe * @param Doctrine\Common\EventSubscriber|array $subscriber */ public function removeEventListener($unsubscribe, $subscriber = NULL) { if ($unsubscribe instanceof EventSubscriber) { $subscriber = $unsubscribe; $unsubscribe = array(); foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { if ((is_array($params) && is_array($params[0])) || !is_numeric($eventName)) { // [EventName => [[method, priority], ...], ...] // [EventName => [method, priority], ...] && [EventName => method, . $unsubscribe[] = $eventName; } else { // [EventName, ...] $unsubscribe[] = $params; } } unset($this->subscribers[spl_object_hash($subscriber)]); } foreach ((array) $unsubscribe as $eventName) { foreach ($this->listeners[$eventName] as $priority => $listeners) { if (($key = array_search($subscriber, $listeners, TRUE)) === FALSE) { continue; } unset($this->listeners[$eventName][$priority][$key]); if (empty($this->listeners[$eventName][$priority])) { unset($this->listeners[$eventName][$priority]); } if (empty($this->listeners[$eventName])) { unset($this->listeners[$eventName]); } // there are no listeners for this specific event, so no reason to call sort on next dispatch $this->sorted[$eventName] = array(); } } } public function addEventSubscriber(EventSubscriber $subscriber) { if (isset($this->subscribers[$hash = spl_object_hash($subscriber)])) { return; } $this->subscribers[$hash] = $subscriber; foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { if (is_numeric($eventName) && is_string($params)) { // [EventName, ...] $this->addEventListener($params, $subscriber); } elseif (is_string($eventName)) { // [EventName => ???, ...] if (is_string($params)) { // [EventName => method, ...] $this->addEventListener($eventName, array($subscriber, $params)); } elseif (is_string($params[0])) { // [EventName => [method, priority], ...] $this->addEventListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0); } else { foreach ($params as $listener) { // [EventName => [[method, priority], ...], ...] $this->addEventListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0); } } } } } public function removeEventSubscriber(EventSubscriber $subscriber) { $this->removeEventListener($subscriber); } /** * @param string|array $name * @param array $defaults * @param string $argsClass * @return Event */ public function createEvent($name, $defaults = array(), $argsClass = NULL) { $event = new Event($name, $defaults, $argsClass); $event->injectEventManager($this); if ($this->panel) { $this->panel->registerEvent($event); } return $event; } private function sortListeners($eventName) { $this->sorted[$eventName] = array(); $available = array(); list($namespace, $event, $separator) = Event::parseName($eventName); $className = $namespace; do { if (empty($this->listeners[$key = ($className ? $className . $separator : '') . $event])) { continue; } $available = $available + array_fill_keys(array_keys($this->listeners[$key]), array()); foreach ($this->listeners[$key] as $priority => $listeners) { foreach ($listeners as $listener) { if ($className === $namespace && in_array($listener, $available[$priority], TRUE)) { continue; } $available[$priority][] = $listener; } } } while ($className && class_exists($className) && ($className = get_parent_class($className))); if (empty($available)) { return; } krsort($available); // [priority => [[listener, ...], ...] $sorted = call_user_func_array('array_merge', $available); $this->sorted[$eventName] = array_map(function ($callable) use ($event) { if ($callable instanceof EventSubscriber) { return $callable; } if (is_object($callable) && method_exists($callable, $event)) { $callable = array($callable, $event); } return $callable; }, $sorted); // [callback, ...] } /*************************** Nette\Object ***************************/ /** * Access to reflection. * @return \Nette\Reflection\ClassType */ public static function getReflection() { return new Nette\Reflection\ClassType(get_called_class()); } /** * Call to undefined method. * * @param string $name * @param array $args * * @throws \Nette\MemberAccessException * @return mixed */ public function __call($name, $args) { return ObjectMixin::call($this, $name, $args); } /** * Call to undefined static method. * * @param string $name * @param array $args * * @throws \Nette\MemberAccessException * @return mixed */ public static function __callStatic($name, $args) { ObjectMixin::callStatic(get_called_class(), $name, $args); } /** * Adding method to class. * * @param $name * @param null $callback * * @throws \Nette\MemberAccessException * @return callable|null */ public static function extensionMethod($name, $callback = NULL) { if (strpos($name, '::') === FALSE) { $class = get_called_class(); } else { list($class, $name) = explode('::', $name); } if ($callback === NULL) { return ObjectMixin::getExtensionMethod($class, $name); } else { ObjectMixin::setExtensionMethod($class, $name, $callback); } } /** * Returns property value. Do not call directly. * * @param string $name * * @throws \Nette\MemberAccessException * @return mixed */ public function &__get($name) { return ObjectMixin::get($this, $name); } /** * Sets value of a property. Do not call directly. * * @param string $name * @param mixed $value * * @throws \Nette\MemberAccessException * @return void */ public function __set($name, $value) { ObjectMixin::set($this, $name, $value); } /** * Is property defined? * * @param string $name * * @return bool */ public function __isset($name) { return ObjectMixin::has($this, $name); } /** * Access to undeclared property. * * @param string $name * * @throws \Nette\MemberAccessException * @return void */ public function __unset($name) { ObjectMixin::remove($this, $name); } } Events-2.4.0/src/Kdyby/Events/IExceptionHandler.php000066400000000000000000000012031251001055300221400ustar00rootroot00000000000000 */ interface IExceptionHandler { /** * Invoked when uncaught exception occurs within event handler * * @param \Exception $exception * @return void */ function handleException(\Exception $exception); } Events-2.4.0/src/Kdyby/Events/LazyEventManager.php000066400000000000000000000041531251001055300220160ustar00rootroot00000000000000 */ class LazyEventManager extends EventManager { /** * @var array */ private $listenerIds; /** * @var \Nette\DI\Container */ private $container; /** * @param array $listenerIds * @param \Nette\DI\Container $container */ public function __construct(array $listenerIds, Nette\DI\Container $container) { $this->listenerIds = $listenerIds; $this->container = $container; } public function setPanel(Diagnostics\Panel $panel) { parent::setPanel($panel); $panel->setServiceIds($this->listenerIds); } /** * @param string $eventName * @param bool $asCallbacks * @return \Doctrine\Common\EventSubscriber[] */ public function getListeners($eventName = NULL) { if (!empty($this->listenerIds[$eventName])) { $this->initializeListener($eventName); } if ($eventName === NULL) { while (($type = key($this->listenerIds)) !== NULL) { $this->initializeListener($type); } } return parent::getListeners($eventName); } /** * @param array|string $unsubscribe * @param Doctrine\Common\EventSubscriber|array $subscriber */ public function removeEventListener($unsubscribe, $subscriber = NULL) { foreach ((array) $unsubscribe as $eventName) { if (array_key_exists($eventName, $this->listenerIds)) { $this->initializeListener($eventName); } } parent::removeEventListener($unsubscribe, $subscriber); } /** * @param string $eventName */ private function initializeListener($eventName) { foreach ($this->listenerIds[$eventName] as $serviceName) { $subscriber = $this->container->getService($serviceName); /** @var Doctrine\Common\EventSubscriber $subscriber */ $this->addEventSubscriber($subscriber); } unset($this->listenerIds[$eventName]); } } Events-2.4.0/src/Kdyby/Events/LifeCycleEvent.php000066400000000000000000000016241251001055300214430ustar00rootroot00000000000000 */ final class LifeCycleEvent extends Nette\Object { /** * Occurs before the application loads presenter */ const onStartup = 'onStartup'; /** * Occurs before the application shuts down */ const onShutdown = 'onShutdown'; /** * Occurs when a new request is ready for dispatch; */ const onRequest = 'onRequest'; /** * Occurs when a new response is received */ const onResponse = 'onResponse'; /** * Occurs when an unhandled exception occurs in the application */ const onError = 'onError'; } Events-2.4.0/src/Kdyby/Events/NamespacedEventManager.php000066400000000000000000000073121251001055300231370ustar00rootroot00000000000000 */ class NamespacedEventManager extends EventManager { /** * @var bool */ public $dispatchGlobalEvents = FALSE; /** * @var EventManager */ private $evm; /** * @var string */ private $namespace; public function __construct($namespace, EventManager $eventManager) { $this->namespace = $namespace; $this->evm = $eventManager; } /** * {@inheritDoc} */ public function dispatchEvent($eventName, Doctrine\Common\EventArgs $eventArgs = null) { list($ns, $event) = Event::parseName($eventName); $this->evm->dispatchEvent($ns !== NULL ? $eventName : $this->namespace . $eventName, $eventArgs); if ($this->dispatchGlobalEvents && $this->evm->hasListeners($event)) { $this->evm->dispatchEvent($event, $eventArgs); } } /** * {@inheritDoc} */ public function getListeners($eventName = null) { if ($eventName === NULL) { $listeners = array(); foreach ($this->evm->getListeners(NULL, TRUE) as $eventName => $subscribers) { list($ns, $event) = Event::parseName($eventName); if ($ns === NULL || stripos($this->namespace, $ns) !== FALSE) { $listeners[$eventName] = $subscribers; } } return $listeners; } list($ns, $event) = Event::parseName($eventName); if ($ns !== NULL) { throw new InvalidArgumentException("Unexpected event with namespace."); } return array_merge( $this->evm->getListeners($event), $this->evm->getListeners($this->namespace . $event) ); } /** * {@inheritDoc} */ public function hasListeners($eventName) { list($ns, $event) = Event::parseName($eventName); if ($ns) { return $this->evm->hasListeners($eventName) || $this->evm->hasListeners($event); } return $this->evm->hasListeners($this->namespace . $eventName) || $this->evm->hasListeners($eventName); } /** * {@inheritDoc} */ public function addEventListener($events, $subscriber, $priority = 0) { foreach ((array) $events as $eventName) { list($ns, $event) = Event::parseName($eventName); $this->evm->addEventListener(array($ns === NULL ? $this->namespace . $event : $eventName), $subscriber); } } /** * {@inheritDoc} */ public function removeEventListener($unsubscribe, $subscriber = NULL) { if ($unsubscribe instanceof Doctrine\Common\EventSubscriber) { $subscriber = $unsubscribe; $unsubscribe = array(); foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { if ((is_array($params) && is_array($params[0])) || !is_numeric($eventName)) { // [EventName => [[method, priority], ...], ...] // [EventName => [method, priority], ...] && [EventName => method, . $unsubscribe[] = $eventName; } else { // [EventName, ...] $unsubscribe[] = $params; } } } $namespace = $this->namespace; $unsubscribe = array_map(function ($eventName) use ($namespace) { list($ns, $event) = Event::parseName($eventName); return $ns === NULL ? $namespace . $event : $eventName; }, (array) $unsubscribe); $this->evm->removeEventListener($unsubscribe, $subscriber); } /** * {@inheritDoc} */ public function setExceptionHandler(IExceptionHandler $exceptionHandler) { throw new NotSupportedException; } /** * {@inheritDoc} */ public function createEvent($name, $defaults = array(), $argsClass = NULL) { return $this->evm->createEvent($this->namespace . $name, $defaults, $argsClass); } } Events-2.4.0/src/Kdyby/Events/Subscriber.php000066400000000000000000000012751251001055300207070ustar00rootroot00000000000000 */ interface Subscriber extends Doctrine\Common\EventSubscriber { } Events-2.4.0/src/Kdyby/Events/SymfonyDispatcher.php000066400000000000000000000033701251001055300222550ustar00rootroot00000000000000 */ class SymfonyDispatcher extends Nette\Object implements EventDispatcherInterface { /** * @var EventManager */ private $evm; public function __construct(EventManager $eventManager) { $this->evm = $eventManager; } public function dispatch($eventName, SymfonyEvent $event = null) { $this->evm->dispatchEvent($eventName, new EventArgsList(array($event))); } public function addListener($eventName, $listener, $priority = 0) { throw new NotSupportedException(); } public function addSubscriber(EventSubscriberInterface $subscriber) { throw new NotSupportedException(); } public function removeListener($eventName, $listener) { throw new NotSupportedException(); } public function removeSubscriber(EventSubscriberInterface $subscriber) { throw new NotSupportedException(); } public function getListeners($eventName = null) { return $this->getListeners($eventName); } public function hasListeners($eventName = null) { return $this->evm->hasListeners($eventName); } } Events-2.4.0/src/Kdyby/Events/exceptions.php000066400000000000000000000023561251001055300207660ustar00rootroot00000000000000 */ interface Exception { } /** * @author Filip Procházka */ class InvalidListenerException extends \RuntimeException implements Exception { } /** * @author Filip Procházka */ class InvalidStateException extends \RuntimeException implements Exception { } class InvalidArgumentException extends \InvalidArgumentException implements Exception { } /** * @author Filip Procházka */ class OutOfRangeException extends \OutOfRangeException implements Exception { } /** * The exception that is thrown when accessing a class member (property or method) fails. * * @author Filip Procházka */ class MemberAccessException extends \LogicException implements Exception { } /** * @author Filip Procházka */ class NotSupportedException extends \LogicException implements Exception { }