public function loadPlugin($name, $file = 'routes.php')
    {
        $plugins = Plugin::getCollection();
        if (!$plugins->has($name)) {
            throw new MissingPluginException(['plugin' => $name]);
        }
        $plugin = $plugins->get($name);

        // @deprecated This block should be removed in 4.0
        if ($file !== 'routes.php') {
            deprecationWarning(
                'Loading plugin routes now uses the routes() hook method on the plugin class. ' .
                'Loading non-standard files will be removed in 4.0'
            );

            $path = $plugin->getConfigPath() . DIRECTORY_SEPARATOR . $file;
            if (!file_exists($path)) {
                throw new InvalidArgumentException(sprintf(
                    'Cannot load routes for the plugin named %s. The %s file does not exist.',
                    $name,
                    $path
                ));
            }

            $routes = $this;
            include $path;

            return;
        }
        $plugin->routes($this);

        // Disable the routes hook to prevent duplicate route issues.
        $plugin->disable('routes');
    }