/** * Set the attributes and requirements on the route. * * @param \Illuminate\Routing\Route $route * @param array $action * @param array $optional * @return void */ protected function setAttributes(Route $route, $action, $optional) { // First we will set the requirement for the HTTP schemes. Some routes may // only respond to requests using the HTTPS scheme, while others might // respond to all, regardless of the scheme, so we'll set that here. if (in_array('https', $action)) { $route->setRequirement('_scheme', 'https'); } if (in_array('http', $action)) { $route->setRequirement('_scheme', 'http'); } // Once the scheme requirements have been made, we will set the before and // after middleware options, which will be used to run any middlewares // by the consuming library, making halting the request cycles easy. if (isset($action['before'])) { $route->setBeforeFilters($action['before']); } if (isset($action['after'])) { $route->setAfterFilters($action['after']); } // If there is a "uses" key on the route it means it is using a controller // instead of a Closures route. So, we'll need to set that as an option // on the route so we can easily do reverse routing ot the route URI. if (isset($action['uses'])) { $route->setOption('_uses', $action['uses']); } if (isset($action['domain'])) { $route->setHost($action['domain']); } // Finally we will go through and set all of the default variables to null // so the developer doesn't have to manually specify one each time they // are declared on a route. This is simply for developer convenience. foreach ($optional as $key) { $route->setDefault($key, null); } }