public static function registerRoutes(Application $app)
    {
        $file = $app['wise.options']['config']['routes'];

        if ('prod' !== $app['wise.options']['mode']) {
            $file .= '_' . $app['wise.options']['mode'];
        }

        $file .= '.' . $app['wise.options']['type'];

        /** @var $wise Wise */
        $wise = $app['wise'];
        $routes = $wise->load($file);
        $collection = new RouteCollection();

        unset($routes['parameters']);
        unset($routes['imports']);

        foreach ($routes as $name => $route) {
            if (null === $route) {
                continue;
            }

            if (isset($route['pattern'])) {
                if (isset($route['path'])) {
                    throw InvalidArgumentException::format(
                        'The "%s" route must not specify both "path" and "pattern".',
                        $name
                    );
                }

                $route['path'] = $route['pattern'];
            }

            $unsupportedKeys = array_diff(
                array_keys($route),
                array_keys(self::$supportedKeys)
            );

            if (!empty($unsupportedKeys)) {
                throw InvalidArgumentException::format(
                    'The "%s" route used unsupported keys (%s). Expected: %s',
                    $name,
                    join(', ', $unsupportedKeys),
                    join(', ', array_keys(self::$supportedKeys))
                );
            }

            foreach (self::$supportedKeys as $key => $value) {
                if (!isset($route[$key])) {
                    $route[$key] = $value;
                }
            }

            $collection->add(
                $name,
                new Route(
                    $route['path'],
                    $route['defaults'],
                    $route['requirements'],
                    $route['options'],
                    $route['host'],
                    $route['schemes'],
                    $route['methods']
                )
            );
        }

        /** @var $routes \Symfony\Component\Routing\RouteCollection */
        $routes = $app['routes'];
        $routes->addCollection($collection);
    }