Set all crud actions, including documentation
Really only usable for the default case
@param $resourceDefinition
@param string $path
@param string $controller
@param $options
@return RouteCollection
@throws \CatLab\Charon\Exceptions\InvalidContextAction
976537
public function resource($resourceDefinition, $path, $controller, $options)
    {
        $id = $options['id'] ?? 'id';
        $only = $options['only'] ?? [ 'index', 'view', 'store', 'edit', 'destroy' ];

        $group = $this->group([]);

        if (in_array('index', $only)) {
            $group->get($path, $controller . '@index')
                ->summary(function () use ($resourceDefinition) {
                    $entityName = ResourceDefinitionLibrary::make($resourceDefinition)->getEntityName(true);
                    return 'Returns all ' . $entityName;
                })
                ->returns()->statusCode(200)->many($resourceDefinition);
        }

        if (in_array('view', $only)) {
            $group->get($path . '/{' . $id . '}', $controller . '@view')
                ->summary(function () use ($resourceDefinition) {
                    $entityName = ResourceDefinitionLibrary::make($resourceDefinition)
                        ->getEntityName(false);

                    return 'View a single ' . $entityName;
                })
                ->parameters()->path($id)->string()->required()
                ->returns()->statusCode(200)->one($resourceDefinition);
        }

        if (in_array('store', $only)) {
            $group->post($path, $controller . '@store')
                ->summary(function () use ($resourceDefinition) {
                    $entityName = ResourceDefinitionLibrary::make($resourceDefinition)
                        ->getEntityName(false);

                    return 'Create a new ' . $entityName;
                })
                ->parameters()->resource($resourceDefinition)->required()
                ->returns()->statusCode(200)->one($resourceDefinition);
        }

        if (in_array('edit', $only)) {
            $group->put($path . '/{' . $id . '}', $controller . '@edit')
                ->summary(function () use ($resourceDefinition) {
                    $entityName = ResourceDefinitionLibrary::make($resourceDefinition)
                        ->getEntityName(false);

                    return 'Update an existing ' . $entityName;
                })
                ->parameters()->path($id)->string()->required()
                ->parameters()->resource($resourceDefinition)->required()
                ->returns()->statusCode(200)->one($resourceDefinition);
        }

        if (in_array('destroy', $only)) {
            $group->delete($path . '/{' . $id . '}', $controller . '@destroy')
                ->summary(function () use ($resourceDefinition) {
                    $entityName = ResourceDefinitionLibrary::make($resourceDefinition)
                        ->getEntityName(false);

                    return 'Delete a ' . $entityName;
                })
                ->parameters()->path($id)->string()->required()
            ;
        }

        return $group;
    }
324222
public function register( $name, $controller, array $options = [] )
	{
		if ( isset( $options['parameters'] ) && !isset( $this->parameters ) )
			$this->parameters = $options['parameters'];

		// If the resource name contains a slash, we will assume the developer wishes to
		// register these resource routes with a prefix so we will set that up out of
		// the box so they don't have to mess with it. Otherwise, we will continue.
		if ( Str::contains( $name, '/' ) )
		{
			$this->prefixedResource( $name, $controller, $options );

			return;
		}

		// We need to extract the base resource from the resource name. Nested resources
		// are supported in the framework, but we need to know what name to use for a
		// place-holder on the route parameters, which should be the base resources.
		$base = $this->getResourceWildcard( last( explode( '.', $name ) ) );

		$defaults = $this->resourceDefaults;

		foreach ( $this->getResourceMethods( $defaults, $options ) as $m )
			$this->{'addResource' . ucfirst( $m )}( $name, $base, $controller, $options );
	}
1251207
public static function resource($url, $controller)
    {
        $route = new self($url);

        $route->targets = ['index', 'show', 'insert', 'add', 'update', 'edit', 'delete'];

        $route->setResourceMethods($url, $controller);

        return $route;
    }
826801
public function initController($controller, $path)
    {
        if($path)
        {
            $controller = $this->name . '\\Controller\\' . $path . '\\' . $controller;
        }
        else
        {
            $controller = $this->name . '\\Controller\\' . $controller;
        }

        return new $controller();
    }
701131
public static function createRouteBuilder($path, array $options = [])
    {
        $defaults = [
            'routeClass' => static::defaultRouteClass(),
            'extensions' => static::$_defaultExtensions,
        ];
        $options += $defaults;

        return new RouteBuilder(static::$_collection, $path, [], [
            'routeClass' => $options['routeClass'],
            'extensions' => $options['extensions'],
        ]);
    }
1082003
public function resource($name, $controller, array $options = array())
    {
        $registrar = $this->getRegistrar();

        $registrar->register($name, $controller, $options);
    }
777833
public function mapCollection(RouteCollection $restRouteCollection)
    {
        $optionsRouteCollection = new RouteCollection();

        foreach ($restRouteCollection->all() as $restRoute) {
            $optionsRouteName = $this->mapper->getOptionsRouteName($restRoute);

            $optionsRoute = $optionsRouteCollection->get($optionsRouteName);
            if ($optionsRoute === null) {
                $optionsRoute = $this->mapper->mapRoute($restRoute);
            } else {
                $optionsRoute = $this->mapper->mergeMethodsDefault($optionsRoute, $restRoute);
            }

            $optionsRouteCollection->add($optionsRouteName, $optionsRoute);
        }

        return $optionsRouteCollection;
    }
191397
private function createResourceController(
        Generator $generator,
        $prefix,
        $controller,
        $model_namespace = ''
    ) {
        $generator->write('controller/rest', [
            'modelNamespace' => $model_namespace,
            'prefix' => $prefix,
            'baseNamespace' => $this->namespaces['controller']
        ]);

        echo Color::green('The controller Rest was well created.');
    }
165805
public function create(
       string $action,
       string $prefix,
       string $controller,
       array $param,
       string $path): RouteInterface
   {
       try {
           return $this->proto->clone()
               ->setAction($action)
               ->setPrefix($prefix)
               ->setController($controller)
               ->setParam($param)
               ->setPath($path);
       } catch (InvalidArgumentException $e) {
           throw new InvalidArgumentException(
               "Can't create route: " . $e->getMessage());
       }
   }
835365
public function load($resource, $type = null)
    {
        $routes = new RouteCollection();

        foreach ($this->pool->getControllers() as $controllerKey => $controller) {
            /** @var CrudController $controller */
            foreach ($controller->getActions() as $actionKey => $action) {
                /** @var ActionInterface $action */
                $options = $action->getOptions();

                $pattern = rtrim($controller->getRoutePrefix() . $options['pattern'], '/');

                $defaults = $options['defaults'];
                $defaults['_controller'] = $controllerKey . ':' . 'callAction';
                $defaults['_action'] = $actionKey;

                $route = new Route(
                    $pattern,
                    $defaults,
                    $options['requirements'],
                    $options['options'],
                    $options['host'],
                    $options['schemes'],
                    $options['methods'],
                    $options['condition']
                );

                $routeSuffix = (empty($options['route_suffix']) ? $actionKey : $options['route_suffix']);
                $routes->add($controllerKey . '.' . $routeSuffix, $route);
            }
        }

        return $routes;
    }
83581
public final function dispatch(
       ContainerInterface $container,
       RouterInterface $router): ControllerInterface
   {
       try {
           $route = $router->match($this->request);
           if (method_exists($container, "set")) {
               $container->set(get_class($this->request), $this->request);
           }
           return $container->get($route->__toString());
       } catch (RouterException $e) {
           throw $e;
       } catch (Throwable $e) {
           throw new DispatcherException(
               "Can't dispatch: " . $e->getMessage());
       }
   }
295036
public static function register($name, $path, $controller, $parameters, $options=array()) {
		static::$routes[$name] = new static($name, $path, $controller, $parameters, $options);
	}
851153
public function resource($name, $controller, array $options = array())
	{
		// If the resource name contains a slash, we will assume the developer wishes to
		// register these resource routes with a prefix so we will set that up out of
		// the box so they don't have to mess with it. Otherwise, we will continue.
		if (str_contains($name, '/'))
		{
			$this->prefixedResource($name, $controller, $options);

			return;
		}

		// We need to extract the base resource from the resource name. Nested resources
		// are supported in the framework, but we need to know what name to use for a
		// place-holder on the route wildcards, which should be the base resources.
		$base = $this->getResourceWildcard(last(explode('.', $name)));

		$defaults = $this->resourceDefaults;

		foreach ($this->getResourceMethods($defaults, $options) as $m)
		{
			$this->{'addResource'.ucfirst($m)}($name, $base, $controller, $options);
		}
	}
845420
protected function configureRoutes(RouteCollection $collection)
    {
        parent::configureRoutes($collection);
        $collection->add('duplicate', $this->getRouterIdParameter() . '/duplicate');
        $collection->add('generateEntityCode');

        /* Needed or not needed ...
         * in sonata-project/admin-bundle/Controller/CRUDController.php
         * the batchAction method
         * throw exception if the http method is not POST
        */
        if ($collection->get('batch')) {
            $collection->get('batch')->setMethods(['POST']);
        }
    }
560181
public function resource($uri, $controller, array $options = [])
    {
        $this->get($uri, "$controller@index", $options);
        $this->post($uri, "$controller@store", $options);
        $this->get("$uri/{placeholder}", "$controller@show", $options);
        $this->put("$uri/{placeholder}", "$controller@update", $options);
        $this->delete("$uri/{placeholder}", "$controller@delete", $options);
    }
363744
protected function addPatchResourceUpdate($name, $base, $controller, $options)
    {
        $uri = $this->getResourceUri($name).'/{'.$base.'}';

        $action = $this->getResourceAction($name, $controller, 'update', $options);

        return $this->router->patch($uri, $action);
    }
608426
public function collection(string $path = ''): CollectionReference
    {
        try {
            return new CollectionReference(Uri::resolve($this->uri, $path), $this->client);
        } catch (\InvalidArgumentException $e) {
            throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
        }
    }