Flame/Modules/DI/ModulesExtension.php
private function addRouters()
	{
		$builder = $this->getContainerBuilder();

		// Get application router
		$router = $builder->getDefinition('router');

		// Init collections
		$routerFactories = array();

		foreach ($builder->findByTag(self::TAG_ROUTER) as $serviceName => $priority) {
			// Priority is not defined...
			if (is_bool($priority)) {
				// ...use default value
				$priority = 100;
			}

			$routerFactories[$priority][$serviceName] = $serviceName;
		}

		// Sort routes by priority
		if (!empty($routerFactories)) {
			krsort($routerFactories, SORT_NUMERIC);

			foreach ($routerFactories as $priority => $items) {
				$routerFactories[$priority] = $items;
			}

			// Process all routes services by priority...
			foreach ($routerFactories as $priority => $items) {
				// ...and by service name...
				foreach($items as $serviceName) {
					$factory = new Nette\DI\Statement(array('@' . $serviceName, 'createRouter'));
					$router->addSetup('offsetSet', array(NULL, $factory));
				}
			}
		}
	}
private function addRouters()
	{
		$builder = $this->getContainerBuilder();

		// Get application router
		$router = $builder->getDefinition('router');

		// Init collections
		$routerFactories = array();

		foreach ($builder->findByTag(self::TAG_ROUTER) as $serviceName => $priority) {
			// Priority is not defined...
			if (is_bool($priority)) {
				// ...use default value
				$priority = 100;
			}

			$routerFactories[$priority][$serviceName] = $serviceName;
		}

		// Sort routes by priority
		if (!empty($routerFactories)) {
			krsort($routerFactories, SORT_NUMERIC);

			foreach ($routerFactories as $priority => $items) {
				$routerFactories[$priority] = $items;
			}

			// Process all routes services by priority...
			foreach ($routerFactories as $priority => $items) {
				// ...and by service name...
				foreach($items as $serviceName) {
					$factory = new Nette\DI\Statement(array('@' . $serviceName, 'createRouter'));
					$router->addSetup('offsetSet', array(NULL, $factory));
				}
			}
		}
	}
Loads all services tagged as router
and adds them to router service

@author: Adam Kadlec <adam.kadlec@gmail.com>
@date: 08.10.14