/**
  * Get all the ResourceFactories for this application.
  *
  * @return ResourceFactory[]
  */
 public function getResources()
 {
     return Std::reduce(function (array $resources, $mapper) {
         if ($mapper instanceof ResourceFactory) {
             return array_merge($resources, [$mapper]);
         } elseif ($mapper instanceof ResourceAggregator) {
             return array_merge($resources, $mapper->getResources());
         }
         return $resources;
     }, [], $this->getRouteAggregator()->getMapperInstances());
 }
 /**
  * Map all the routes contained in every resource factory.
  *
  * @param Router $router
  *
  * @return Router
  */
 public function map(Router $router)
 {
     return Std::reduce(function (Router $router, ResourceFactory $factory) {
         return $factory->inject($router);
     }, $router, $this->getResources());
 }
 /**
  * Get instances of the defined mappers.
  *
  * @return RouteMapper[]
  */
 public function getMapperInstances()
 {
     return Std::reduce(function (array $mappers, $mapperName) {
         if ($mapperName instanceof RouteMapper) {
             return array_merge($mappers, [$mapperName]);
         }
         /** @var RouteMapper $mapper */
         $mapper = $this->app->make($mapperName);
         return array_merge($mappers, [$mapper]);
     }, [], $this->getMappers());
 }