addRouteByConfigs

@param array                  $routes
@param string|AbstractPackage $package

@return  static
972819
public function addRouteByConfigs(array $routes, $package = null)
    {
        foreach ($routes as $key => $route) {
            $this->addRouteByConfig($key, $route, $package);
        }

        return $this;
    }
1268199
public function withPackage($packages)
    {
        $packages = is_array($packages)
            ? $packages
            : func_get_args();

        $this->package->with($packages);

        return $this;
    }
175648
public function setPackage(AbstractPackage $package)
    {
        $this->package = $package;

        $this->config['package.name'] = $package->getName();
        $this->config['package.path'] = $package->getDir();

        return $this;
    }
295004
private function setRoutes(array $routes)
    {
        $this->routes = [];

        foreach ($routes as $name => $route) {
            $this->add($name, $route);
        }
    }
662403
public function registerRawRouting(array $routes, PackageResolver $resolver)
    {
        foreach ($routes as $key => &$route) {
            // Package
            if (isset($route['package'])) {
                if (!isset($route['pattern'])) {
                    throw new \InvalidArgumentException(sprintf('Route need pattern: %s', print_r($route, true)));
                }

                if (!$resolver->exists($route['package'])) {
                    throw new \InvalidArgumentException(sprintf(
                        'Package %s not exists when register routing: %s.',
                        $route['package'],
                        $key
                    ));
                }

                $package = $resolver->getPackage($route['package']);

                $package->loadRouting($this, $route['pattern']);

                continue;
            }

            // Simple route
            $this->addRouteByConfig($key, $route);
        }

        return $this;
    }
970021
protected function registerRoutes(array $routes)
    {
        foreach ($routes as $route => $config) {
            $this->registerRoute($route, $config);
        }
    }
719463
public function add(Package $package)
    {
        $name = $package->getName();
        if (isset($this->packages[$name])) {
            return;
        }

        $this->packages[$name] = $package;
    }
735736
protected function installRouting(AbstractPackage $package)
    {
        if (!(new BooleanPrompter)->ask('Do your want to add routing profile to <comment>etc/routing.php</comment>? [Y/n]: ',
            true)) {
            return;
        }

        $pattern = (new TextPrompter)->ask('The URL pattern prefix [<info>/' . $package->name . '</info>]: ',
            '/' . $package->name);

        $routing = <<<ROUTE

// Routing of package: %s
\$router->registerPackage('%s', '%s');

ROUTE;

        $routing = sprintf($routing, $package->name, $package->name, $pattern);

        $target = $this->console->get('path.etc') . '/routing.php';

        $content = file_get_contents($target);
        $content .= $routing;

        file_put_contents($target, $content);

        $this->out()->out('  Added routing profile to <comment>etc/routing.php</comment>');
    }
1070740
public function addRoute($methods, $pattern, $handler, array $requirements = [], array $defaults = [])
    {
        list ($name, $host, $schemes, $constraints) = $this->parseRequirements(
            $this->extendRequirements($requirements),
            $methods
        );

        $route = new Route(
            $this->prefixPattern($pattern),
            $handler,
            is_array($methods) ? $methods : explode('|', $methods),
            $host,
            $defaults,
            $constraints,
            is_array($schemes) ? $schemes : explode('|', $schemes)
        );

        $this->routes->add($name, $route);
    }
808160
private function createPackages(array $packages)
    {
        $matcherPackages = [];

        foreach ($packages as $package) {
            $reflection = new ReflectionClass($package);

            if ($reflection->implementsInterface(self::PACKAGE_REGISTRAR) === false) {
                throw NotAvailableException::createForPackage(self::PACKAGE_REGISTRAR);
            }
            $matcherPackages[] = $reflection->newInstance();
        }

        return $matcherPackages;
    }
448594
public static function route(): AbstractRoute
    {
        if (static::$routing === null) {
            $config = static::getConfig('application');
            $routingClassName = $config->get('routing_class');
            $routeOptions = $config->get('routing_options') ?? [];

            if ($routingClassName == null) {
                static::terminateWithError('Can not init routing class when routing_class is not set in application config');
            }

            static::$routing = new $routingClassName($routeOptions);
        }

        return static::$routing;
    }
565287
public function addConfigComponent($package, $namespace, $path)
    {
        if ($this->hasPackageRepository()) {
            $this->app->make('config')->package($package, $path, $namespace);
        }
    }
897397
public function addRoutes($routes)
	{
		foreach ($routes as $route) {
			foreach (explode('|', $route[0]) as $method) {
				$this->routes[$method][] = array(
					'pattern' => $route[1],
					'callable' => $route[2]
				);
			}
		}
	}
1309298
public static function add($route){
      if (is_a($route, 'Route')){

        // Add to tag map
        if ($route->tag) static::$tags[$route->tag] =& $route;

        // Optimize tree
        if (Options::get('core.route.auto_optimize', true)){
          $base =& static::$optimized_tree;
          foreach (explode('/',trim(preg_replace('#^(.+?)\(?:.+$#','$1',$route->URLPattern),'/')) as $segment) {
            $segment = trim($segment,'(');
            if (!isset($base[$segment])) $base[$segment] = [];
            $base =& $base[$segment];
          }
          $base[] =& $route;
        }
      }

      // Add route to active group
      if ( isset(static::$group[0]) ) static::$group[0]->add($route);

      return static::$routes[implode('', static::$prefix)][] = $route;
    }
1110910
public static function routeMiddleware( $routeMiddleware = array() ) {
		$packageRouteMiddleware = array();
		$path = base_path('config/packages.json');
		if( file_exists( $path ) ) {
			$data = json_decode( file_get_contents( $path ) );
			if( isset( $data->routeMiddleware ) ) {
				$packageRouteMiddleware = (array)$data->routeMiddleware;
			}
		}
		//dd(array_merge( $packageRouteMiddleware, $routeMiddleware ));
		return array_merge( $packageRouteMiddleware, $routeMiddleware );
	}
288230
protected function addPackage(ComposerPackage $package)
    {
        $plugin = $this->rep->find($package->getName());

        // create new plugin if not exists
        if (!$plugin) {
            $plugin = new Plugin();
            $plugin->setName($package->getName());
        }

        list($vendor, $package) = explode('/', $plugin->getName());

        try {
            $data = $this->client->getPlugin($vendor, $package);
            $plugin->setTitle($data['title'])->setDescription($data['description']);
            if ($data['logo']) {
                $this->downloader->entity($data['logo'], $plugin, true);
            }
        } catch (\Exception $e) {
            // is not a critical error
        }

        $this->em->persist($plugin);
        $this->em->flush();
    }
246717
public function addOnRoute($name, array $routes)
    {
        $route = $this->findRoute($name);

        // if has subroutes, use the that subroutes, else, create a new subroute.
        if($route->hasSubroutes())
            $route->getSubroutes()->addRoutes($routes);
        else
            $route->setSubroutes($routes);

        return $this;
    }