public function getRouteCollectionForType($type)
    {
        if (isset($this->collections[$type])) {
            return $this->collections[$type];
        }

        if (!$this->metadataFactory->hasMetadataFor($type)) {
            throw new ResourceNotFoundException(sprintf('No metadata found for module type "%s".', $type));
        }

        $metadata = $this->metadataFactory->getMetadataFor($type);
        $routes   = $metadata->getRoutes();

        // Add modular prefix to the collection
        $this->provider->addModularPrefix($routes);

        // Add route prefix to the collection
        $routes->addPrefix(
            $this->routePrefix['path'],
            $this->routePrefix['defaults'],
            $this->routePrefix['requirements']
        );

        return $this->collections[$type] = $routes;
    }