diff --git a/composer.json b/composer.json index b0e68eed2d2..0417960efa0 100755 --- a/composer.json +++ b/composer.json @@ -17,7 +17,6 @@ "classpreloader/classpreloader": "~1.0.2", "danielstjules/stringy": "~1.5", "d11wtq/boris": "~1.0", - "doctrine/annotations": "~1.0", "doctrine/inflector": "~1.0", "ircmaxell/password-compat": "~1.0", "jeremeamia/superclosure": "~1.0.1", diff --git a/src/Illuminate/Events/Annotations/Annotations/Hears.php b/src/Illuminate/Events/Annotations/Annotations/Hears.php deleted file mode 100644 index eefef25a14b..00000000000 --- a/src/Illuminate/Events/Annotations/Annotations/Hears.php +++ /dev/null @@ -1,26 +0,0 @@ -events = (array) $values['value']; - } - -} diff --git a/src/Illuminate/Events/Annotations/Scanner.php b/src/Illuminate/Events/Annotations/Scanner.php deleted file mode 100644 index 3cbf1131ae1..00000000000 --- a/src/Illuminate/Events/Annotations/Scanner.php +++ /dev/null @@ -1,120 +0,0 @@ -scan = $scan; - - foreach (Finder::create()->files()->in(__DIR__.'/Annotations') as $file) - { - AnnotationRegistry::registerFile($file->getRealPath()); - } - } - - /** - * Create a new scanner instance. - * - * @param array $scan - * @return static - */ - public static function create(array $scan) - { - return new static($scan); - } - - /** - * Convert the scanned annotations into route definitions. - * - * @return string - */ - public function getEventDefinitions() - { - $output = ''; - - $reader = $this->getReader(); - - foreach ($this->getClassesToScan() as $class) - { - foreach ($class->getMethods() as $method) - { - foreach ($reader->getMethodAnnotations($method) as $annotation) - { - $output .= $this->buildListener($class->name, $method->name, $annotation->events); - } - } - } - - return trim($output); - } - - /** - * Build the event listener for the class and method. - * - * @param string $class - * @param string $method - * @param array $events - * @return string - */ - protected function buildListener($class, $method, $events) - { - return sprintf('$events->listen(%s, \''.$class.'@'.$method.'\');', var_export($events, true)).PHP_EOL; - } - - /** - * Get all of the ReflectionClass instances in the scan path. - * - * @return array - */ - protected function getClassesToScan() - { - $classes = []; - - foreach ($this->scan as $class) - { - try - { - $classes[] = new ReflectionClass($class); - } - catch (Exception $e) - { - // - } - } - - return $classes; - } - - /** - * Get an annotation reader instance. - * - * @return \Doctrine\Common\Annotations\SimpleAnnotationReader - */ - protected function getReader() - { - with($reader = new SimpleAnnotationReader) - ->addNamespace('Illuminate\Events\Annotations\Annotations'); - - return $reader; - } - -} diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index e5452366b17..7ec63d3a5f1 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -629,46 +629,6 @@ public function getCachedRoutesPath() return $this['path.storage'].'/framework/routes.php'; } - /** - * Determine if the application routes have been scanned. - * - * @return bool - */ - public function routesAreScanned() - { - return $this['files']->exists($this->getScannedRoutesPath()); - } - - /** - * Get the path to the scanned routes file. - * - * @return string - */ - public function getScannedRoutesPath() - { - return $this['path.storage'].'/framework/routes.scanned.php'; - } - - /** - * Determine if the application events have been scanned. - * - * @return bool - */ - public function eventsAreScanned() - { - return $this['files']->exists($this->getScannedEventsPath()); - } - - /** - * Get the path to the scanned events file. - * - * @return string - */ - public function getScannedEventsPath() - { - return $this['path.storage'].'/framework/events.scanned.php'; - } - /** * Call the booting callbacks for the application. * diff --git a/src/Illuminate/Foundation/Console/EventScanCommand.php b/src/Illuminate/Foundation/Console/EventScanCommand.php deleted file mode 100644 index 0104edcc2f1..00000000000 --- a/src/Illuminate/Foundation/Console/EventScanCommand.php +++ /dev/null @@ -1,92 +0,0 @@ -files = $files; - } - - /** - * Execute the console command. - * - * @return void - */ - public function fire() - { - $this->files->put($this->getOutputPath(), $this->getEventDefinitions()); - - $this->info('Events scanned!'); - } - - /** - * Get the route definitions for the annotations. - * - * @return string - */ - protected function getEventDefinitions() - { - $provider = 'Illuminate\Foundation\Support\Providers\EventServiceProvider'; - - return 'laravel->getProvider($provider)->scans() - )->getEventDefinitions().PHP_EOL; - } - - /** - * Get the path to which the routes should be written. - * - * @return string - */ - protected function getOutputPath() - { - return $this->laravel['path.storage'].'/framework/events.scanned.php'; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['path', null, InputOption::VALUE_OPTIONAL, 'The path to scan.'], - ]; - } - -} diff --git a/src/Illuminate/Foundation/Console/RouteScanCommand.php b/src/Illuminate/Foundation/Console/RouteScanCommand.php deleted file mode 100644 index 913e49ef4e1..00000000000 --- a/src/Illuminate/Foundation/Console/RouteScanCommand.php +++ /dev/null @@ -1,99 +0,0 @@ -files = $files; - } - - /** - * Execute the console command. - * - * @return void - */ - public function fire() - { - $this->files->put($this->getOutputPath(), $this->getRouteDefinitions()); - - $this->info('Routes scanned!'); - } - - /** - * Get the route definitions for the annotations. - * - * @return string - */ - protected function getRouteDefinitions() - { - $provider = 'Illuminate\Foundation\Support\Providers\RouteServiceProvider'; - - return 'laravel->getProvider($provider)->scans() - )->getRouteDefinitions().PHP_EOL; - } - - /** - * Get the path to which the routes should be written. - * - * @return string - */ - protected function getOutputPath() - { - return $this->laravel['path.storage'].'/framework/routes.scanned.php'; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - $namespace = $this->getAppNamespace().'Http\Controllers'; - - return [ - ['namespace', null, InputOption::VALUE_OPTIONAL, 'The root namespace for the controllers.', $namespace], - - ['path', null, InputOption::VALUE_OPTIONAL, 'The path to scan.', 'Http'.DIRECTORY_SEPARATOR.'Controllers'], - ]; - } - -} diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index d7d94056f66..550b2691355 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -7,9 +7,7 @@ use Illuminate\Foundation\Console\AppNameCommand; use Illuminate\Foundation\Console\OptimizeCommand; use Illuminate\Foundation\Console\RouteListCommand; -use Illuminate\Foundation\Console\RouteScanCommand; use Illuminate\Foundation\Console\EventMakeCommand; -use Illuminate\Foundation\Console\EventScanCommand; use Illuminate\Foundation\Console\RouteCacheCommand; use Illuminate\Foundation\Console\RouteClearCommand; use Illuminate\Foundation\Console\CommandMakeCommand; @@ -48,7 +46,6 @@ class ArtisanServiceProvider extends ServiceProvider { 'EventMake' => 'command.event.make', 'Down' => 'command.down', 'Environment' => 'command.environment', - 'EventScan' => 'command.event.scan', 'HandlerCommand' => 'command.handler.command', 'HandlerEvent' => 'command.handler.event', 'KeyGenerate' => 'command.key.generate', @@ -58,7 +55,6 @@ class ArtisanServiceProvider extends ServiceProvider { 'RouteCache' => 'command.route.cache', 'RouteClear' => 'command.route.clear', 'RouteList' => 'command.route.list', - 'RouteScan' => 'command.route.scan', 'Tinker' => 'command.tinker', 'Up' => 'command.up', ]; @@ -197,19 +193,6 @@ protected function registerEnvironmentCommand() }); } - /** - * Register the command. - * - * @return void - */ - protected function registerEventScanCommand() - { - $this->app->singleton('command.event.scan', function($app) - { - return new EventScanCommand($app['files']); - }); - } - /** * Register the command. * @@ -327,19 +310,6 @@ protected function registerRouteListCommand() }); } - /** - * Register the command. - * - * @return void - */ - protected function registerRouteScanCommand() - { - $this->app->singleton('command.route.scan', function($app) - { - return new RouteScanCommand($app['files']); - }); - } - /** * Register the command. * diff --git a/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php b/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php index b83f88b17d7..28e1026f0eb 100644 --- a/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php +++ b/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php @@ -1,32 +1,17 @@ app->environment('local') && $this->scanWhenLocal) - { - $this->scanEvents(); - } - - if ( ! empty($this->scan) && $this->app->eventsAreScanned()) - { - $this->loadScannedEvents(); - } - foreach ($this->listen as $event => $listeners) { foreach ($listeners as $listener) @@ -52,41 +27,13 @@ public function boot(DispatcherContract $events) $events->listen($event, $listener); } } - + foreach ($this->subscribe as $subscriber) { $events->subscribe($subscriber); } } - /** - * Load the scanned events for the application. - * - * @return void - */ - protected function loadScannedEvents() - { - $events = app('Illuminate\Contracts\Events\Dispatcher'); - - require $this->app->getScannedEventsPath(); - } - - /** - * Scan the events for the application. - * - * @return void - */ - protected function scanEvents() - { - if (empty($this->scan)) return; - - $scanner = new Scanner($this->scan); - - file_put_contents( - $this->app->getScannedEventsPath(), 'getEventDefinitions() - ); - } - /** * {@inheritdoc} */ @@ -95,14 +42,4 @@ public function register() // } - /** - * Get the classes to be scanned by the provider. - * - * @return array - */ - public function scans() - { - return $this->scan; - } - } diff --git a/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php b/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php index 207945ac669..deced66024c 100644 --- a/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php +++ b/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php @@ -2,7 +2,6 @@ use Illuminate\Routing\Router; use Illuminate\Support\ServiceProvider; -use Illuminate\Routing\Annotations\Scanner; class RouteServiceProvider extends ServiceProvider { @@ -13,20 +12,6 @@ class RouteServiceProvider extends ServiceProvider { */ protected $namespace = ''; - /** - * The controllers to scan for route annotations. - * - * @var array - */ - protected $scan = []; - - /** - * Determines if we will auto-scan in the local environment. - * - * @var bool - */ - protected $scanWhenLocal = false; - /** * Bootstrap any application services. * @@ -80,16 +65,6 @@ protected function loadCachedRoutes() */ protected function loadRoutes() { - if ($this->app->environment('local') && $this->scanWhenLocal) - { - $this->scanRoutes(); - } - - if ( ! empty($this->scan) && $this->app->routesAreScanned()) - { - $this->loadScannedRoutes(); - } - $this->app->call([$this, 'map']); } @@ -109,35 +84,6 @@ protected function loadRoutesFrom($path) }); } - /** - * Scan the routes and write the scanned routes file. - * - * @return void - */ - protected function scanRoutes() - { - if (empty($this->scan)) return; - - $scanner = new Scanner($this->scan); - - file_put_contents($this->app->getScannedRoutesPath(), 'getRouteDefinitions()); - } - - /** - * Load the scanned application routes. - * - * @return void - */ - protected function loadScannedRoutes() - { - $this->app->booted(function() - { - $router = app('Illuminate\Contracts\Routing\Registrar'); - - require $this->app->getScannedRoutesPath(); - }); - } - /** * Register the service provider. * @@ -145,16 +91,6 @@ protected function loadScannedRoutes() */ public function register() {} - /** - * Get the classes to be scanned by the provider. - * - * @return array - */ - public function scans() - { - return $this->scan; - } - /** * Pass dynamic methods onto the router instance. * diff --git a/src/Illuminate/Routing/Annotations/AbstractPath.php b/src/Illuminate/Routing/Annotations/AbstractPath.php deleted file mode 100644 index bdfdf997217..00000000000 --- a/src/Illuminate/Routing/Annotations/AbstractPath.php +++ /dev/null @@ -1,40 +0,0 @@ -class = $reader->getClassAnnotations($class); - $this->method = $this->getMethodAnnotations($class, $reader); - } - - /** - * Get the method annotations for a given class. - * - * @param \ReflectionClass $class - * @param \Doctrine\Common\Annotations\SimpleAnnotationReader $reader - * @return array - */ - protected function getMethodAnnotations(ReflectionClass $class, SimpleAnnotationReader $reader) - { - $annotations = []; - - foreach ($class->getMethods() as $method) - { - $results = $reader->getMethodAnnotations($method); - - if (count($results) > 0) - $annotations[$method->name] = $results; - } - - return $annotations; - } - -} diff --git a/src/Illuminate/Routing/Annotations/Annotations/Annotation.php b/src/Illuminate/Routing/Annotations/Annotations/Annotation.php deleted file mode 100644 index 9250e7c0ddc..00000000000 --- a/src/Illuminate/Routing/Annotations/Annotations/Annotation.php +++ /dev/null @@ -1,124 +0,0 @@ -values = $values; - } - - /** - * Apply the annotation's settings to the given endpoint. - * - * @param \Illuminate\Routing\Annotations\MethodEndpoint $endpoint - * @param \ReflectionMethod $method - * @return void - */ - public function modify(MethodEndpoint $endpoint, ReflectionMethod $method) - { - // - } - - /** - * Apply the annotation's settings to the given endpoint collection. - * - * @param \Illuminate\Routing\Annotations\EndpointCollection $endpoints - * @param \ReflectionClass $class - * @return void - */ - public function modifyCollection(EndpointCollection $endpoints, ReflectionClass $class) - { - // - } - - /** - * Determine if the value at a given offset exists. - * - * @param string $offset - * @return bool - */ - public function offsetExists($offset) - { - return array_key_exists($offset, $this->values); - } - - /** - * Get the value at a given offset. - * - * @param string $offset - * @return mixed - */ - public function offsetGet($offset) - { - return $this->values[$offset]; - } - - /** - * Set the value at a given offset. - * - * @param string $offset - * @param mixed $value - * @return void - */ - public function offsetSet($offset, $value) - { - $this->values[$offset] = $value; - } - - /** - * Remove the value at a given offset. - * - * @param string $offset - * @return void - */ - public function offsetUnset($offset) - { - unset($this->values[$offset]); - } - - /** - * Dynamically get a property on the annotation. - * - * @param string $key - * @return mixed - */ - public function __get($key) - { - if ($this->offsetExists($key)) - { - return $this->values[$key]; - } - } - - /** - * Dynamically set a property on the annotation. - * - * @param string $key - * @param mixed $value - * @return void - */ - public function __set($key, $value) - { - $this->values[$key] = $value; - } - -} diff --git a/src/Illuminate/Routing/Annotations/Annotations/Controller.php b/src/Illuminate/Routing/Annotations/Annotations/Controller.php deleted file mode 100644 index 3aa791ddc79..00000000000 --- a/src/Illuminate/Routing/Annotations/Annotations/Controller.php +++ /dev/null @@ -1,61 +0,0 @@ -prefix) $this->prefixEndpoints($endpoints); - - if ($this->domain) $this->setEndpointDomains($endpoints); - } - - /** - * Set the prefixes on the endpoints. - * - * @param EndpointCollection $endpoints - * @return void - */ - protected function prefixEndpoints(EndpointCollection $endpoints) - { - foreach ($endpoints->getAllPaths() as $path) - { - $path->path = $this->trimPath($this->prefix, $path->path); - } - } - - /** - * Set the domain on the endpoints. - * - * @param EndpointCollection $endpoints - * @return void - */ - protected function setEndpointDomains(EndpointCollection $endpoints) - { - foreach ($endpoints->getAllPaths() as $path) - { - if (is_null($path->domain)) $path->domain = $this->domain; - } - } - - /** - * Trim the path slashes for a given prefix and path. - * - * @param string $prefix - * @param string $path - * @return string - */ - protected function trimPath($prefix, $path) - { - return trim(trim($prefix, '/').'/'.trim($path, '/'), '/'); - } - -} diff --git a/src/Illuminate/Routing/Annotations/Annotations/Delete.php b/src/Illuminate/Routing/Annotations/Annotations/Delete.php deleted file mode 100644 index 6b45cbd171a..00000000000 --- a/src/Illuminate/Routing/Annotations/Annotations/Delete.php +++ /dev/null @@ -1,10 +0,0 @@ -hasPaths()) - { - foreach ($endpoint->getPaths() as $path) - { - $path->middleware = array_merge($path->middleware, (array) $this->value); - } - } - else - { - $endpoint->middleware = array_merge($endpoint->middleware, (array) $this->value); - } - } - - /** - * {@inheritdoc} - */ - public function modifyCollection(EndpointCollection $endpoints, ReflectionClass $class) - { - foreach ($endpoints as $endpoint) - { - foreach ((array) $this->value as $middleware) - { - $endpoint->classMiddleware[] = [ - 'name' => $middleware, 'only' => (array) $this->only, 'except' => (array) $this->except - ]; - } - } - } - -} diff --git a/src/Illuminate/Routing/Annotations/Annotations/Options.php b/src/Illuminate/Routing/Annotations/Annotations/Options.php deleted file mode 100644 index fa973e26685..00000000000 --- a/src/Illuminate/Routing/Annotations/Annotations/Options.php +++ /dev/null @@ -1,10 +0,0 @@ -push(new ResourceEndpoint([ - 'reflection' => $class, 'name' => $this->value, 'names' => (array) $this->names, - 'only' => (array) $this->only, 'except' => (array) $this->except, - 'middleware' => $this->getMiddleware($endpoints), - ])); - } - - /** - * Get all of the middleware defined on the resource method endpoints. - * - * @param \Illuminate\Routing\Annotations\EndpointCollection $endpoints - * @return array - */ - protected function getMiddleware(EndpointCollection $endpoints) - { - return $this->extractFromEndpoints($endpoints, 'middleware'); - } - - /** - * Extract method items from endpoints for the given key. - * - * @param \Illuminate\Routing\Annotations\EndpointCollection $endpoints - * @param string $key - * @return array - */ - protected function extractFromEndpoints(EndpointCollection $endpoints, $key) - { - $items = [ - 'index' => [], 'create' => [], 'store' => [], 'show' => [], - 'edit' => [], 'update' => [], 'destroy' => [] - ]; - - foreach ($this->getEndpointsWithResourceMethods($endpoints, $key) as $endpoint) - $items[$endpoint->method] = array_merge($items[$endpoint->method], $endpoint->{$key}); - - return $items; - } - - /** - * Get all of the resource method endpoints with pathless filters. - * - * @param \Illuminate\Routing\Annotations\EndpointCollection $endpoints - * @return array - */ - protected function getEndpointsWithResourceMethods(EndpointCollection $endpoints) - { - return Collection::make($endpoints)->filter(function($endpoint) - { - return ($endpoint instanceof MethodEndpoint && - in_array($endpoint->method, $this->methods)); - - })->all(); - } - -} diff --git a/src/Illuminate/Routing/Annotations/Annotations/Route.php b/src/Illuminate/Routing/Annotations/Annotations/Route.php deleted file mode 100644 index df7ddcf055a..00000000000 --- a/src/Illuminate/Routing/Annotations/Annotations/Route.php +++ /dev/null @@ -1,20 +0,0 @@ -addPath(new Path( - strtolower(class_basename(get_class($this))), $this->domain, $this->value, - $this->as, (array) $this->middleware, (array) $this->where - )); - } - -} diff --git a/src/Illuminate/Routing/Annotations/Annotations/Where.php b/src/Illuminate/Routing/Annotations/Annotations/Where.php deleted file mode 100644 index e3b3b8446d1..00000000000 --- a/src/Illuminate/Routing/Annotations/Annotations/Where.php +++ /dev/null @@ -1,35 +0,0 @@ -getPaths() as $path) - { - $path->where = array_merge($path->where, (array) $this->value); - } - } - - /** - * {@inheritdoc} - */ - public function modifyCollection(EndpointCollection $endpoints, ReflectionClass $class) - { - foreach ($endpoints->getAllPaths() as $path) - { - $path->where = array_merge($path->where, $this->value); - } - } - -} diff --git a/src/Illuminate/Routing/Annotations/EndpointCollection.php b/src/Illuminate/Routing/Annotations/EndpointCollection.php deleted file mode 100644 index 96dbde8230b..00000000000 --- a/src/Illuminate/Routing/Annotations/EndpointCollection.php +++ /dev/null @@ -1,27 +0,0 @@ -getPaths() as $path) - { - $paths[] = $path; - } - } - - return $paths; - } - -} diff --git a/src/Illuminate/Routing/Annotations/EndpointInterface.php b/src/Illuminate/Routing/Annotations/EndpointInterface.php deleted file mode 100644 index 1942081c7f5..00000000000 --- a/src/Illuminate/Routing/Annotations/EndpointInterface.php +++ /dev/null @@ -1,42 +0,0 @@ -method; - } - - /** - * Add the given path definition to the endpoint. - * - * @param \Illuminate\Routing\Annotations\AbstractPath $path - * @return void - */ - public function addPath(AbstractPath $path) - { - $this->paths[] = $path; - } - - /** - * Implode the given list into a comma separated string. - * - * @param array $array - * @return string - */ - protected function implodeArray(array $array) - { - $results = []; - - foreach ($array as $key => $value) - { - if (is_string($key)) - { - $results[] = "'".$key."' => '".$value."'"; - } - else - { - $results[] = "'".$value."'"; - } - } - - return count($results) > 0 ? implode(', ', $results) : ''; - } - -} diff --git a/src/Illuminate/Routing/Annotations/MethodEndpoint.php b/src/Illuminate/Routing/Annotations/MethodEndpoint.php deleted file mode 100644 index 0fa7ec1baf6..00000000000 --- a/src/Illuminate/Routing/Annotations/MethodEndpoint.php +++ /dev/null @@ -1,152 +0,0 @@ - $value) - $this->{$key} = $value; - } - - /** - * Transform the endpoint into a route definition. - * - * @return string - */ - public function toRouteDefinition() - { - $routes = []; - - foreach ($this->paths as $path) - { - $routes[] = sprintf( - $this->getTemplate(), $path->verb, $path->path, $this->uses, var_export($path->as, true), - $this->getMiddleware($path), $this->implodeArray($path->where), var_export($path->domain, true) - ); - } - - return implode(PHP_EOL.PHP_EOL, $routes); - } - - /** - * Get the middleware for the path. - * - * @param \Illuminate\Routing\Annotations\AbstractPath $path - * @return array - */ - protected function getMiddleware(AbstractPath $path) - { - $classMiddleware = $this->getClassMiddlewareForPath($path)->all(); - - return $this->implodeArray( - array_merge($classMiddleware, $path->middleware, $this->middleware) - ); - } - - /** - * Get the class middleware for the given path. - * - * @param \Illuminate\Routing\Annotations\AbstractPath $path - * @return array - */ - protected function getClassMiddlewareForPath(AbstractPath $path) - { - return Collection::make($this->classMiddleware)->filter(function($m) - { - return $this->middlewareAppliesToMethod($this->method, $m); - }) - ->map(function($m) - { - return $m['name']; - }); - } - - /** - * Determine if the endpoint has any paths. - * - * @return bool - */ - public function hasPaths() - { - return count($this->paths) > 0; - } - - /** - * Get all of the path definitions for an endpoint. - * - * @return array - */ - public function getPaths() - { - return $this->paths; - } - - /** - * Get the template for the endpoint. - * - * @return string - */ - protected function getTemplate() - { - return '$router->%s(\'%s\', [ - \'uses\' => \'%s\', - \'as\' => %s, - \'middleware\' => [%s], - \'where\' => [%s], - \'domain\' => %s, -]);'; - } - -} diff --git a/src/Illuminate/Routing/Annotations/Path.php b/src/Illuminate/Routing/Annotations/Path.php deleted file mode 100644 index fbac97a8be8..00000000000 --- a/src/Illuminate/Routing/Annotations/Path.php +++ /dev/null @@ -1,33 +0,0 @@ -as = $as; - $this->verb = $verb; - $this->where = $where; - $this->domain = $domain; - $this->middleware = $middleware; - $this->path = $path == '/' ? '/' : trim($path, '/'); - } - -} diff --git a/src/Illuminate/Routing/Annotations/ResourceEndpoint.php b/src/Illuminate/Routing/Annotations/ResourceEndpoint.php deleted file mode 100644 index 1d214ba597d..00000000000 --- a/src/Illuminate/Routing/Annotations/ResourceEndpoint.php +++ /dev/null @@ -1,226 +0,0 @@ - $value) - { - $this->{$key} = $value; - } - - $this->buildPaths(); - } - - /** - * Build all of the paths for the resource endpoint. - * - * @return void - */ - protected function buildPaths() - { - foreach ($this->getIncludedMethods() as $method) - { - $this->paths[] = new ResourcePath($method); - } - } - - /** - * Get the methods to be included in the resource. - * - * @return array - */ - protected function getIncludedMethods() - { - if ($this->only) - { - return $this->only; - } - elseif ($this->except) - { - return array_diff($this->methods, $this->except); - } - - return $this->methods; - } - - /** - * Transform the endpoint into a route definition. - * - * @return string - */ - public function toRouteDefinition() - { - $routes = []; - - foreach ($this->paths as $path) - { - $routes[] = sprintf( - $this->getTemplate(), 'Resource: '.$this->name.'@'.$path->method, - $this->implodeArray($this->getMiddleware($path)), - var_export($path->path, true), $this->implodeArray($path->where), - var_export($path->domain, true), var_export($this->name, true), - var_export($this->reflection->name, true), $this->implodeArray([$path->method]), - $this->implodeArray($this->getNames($path)) - ); - } - - return implode(PHP_EOL.PHP_EOL, $routes); - } - - /** - * Get all of the middleware for the given path. - * - * This will also merge in any of the middleware applied at the route level. - * - * @param ResourcePath $path - * @return array - */ - protected function getMiddleware(ResourcePath $path) - { - $classMiddleware = $this->getClassMiddlewareForPath($path)->all(); - - return array_merge($classMiddleware, array_get($this->middleware, $path->method, [])); - } - - /** - * Get the class middleware for the given path. - * - * @param ResourcePath $path - * @return array - */ - protected function getClassMiddlewareForPath(ResourcePath $path) - { - return Collection::make($this->classMiddleware)->filter(function($m) use ($path) - { - return $this->middlewareAppliesToMethod($path->method, $m); - }) - ->map(function($m) - { - return $m['name']; - }); - } - - /** - * Get the names for the given path. - * - * @param ResourcePath $path - * @return array - */ - protected function getNames(ResourcePath $path) - { - return isset($this->names[$path->method]) ? [$path->method => $this->names[$path->method]] : []; - } - - /** - * Determine if the endpoint has any paths. - * - * @return bool - */ - public function hasPaths() - { - return count($this->paths) > 0; - } - - /** - * Get all of the path definitions for an endpoint. - * - * @return array[AbstractPath] - */ - public function getPaths() - { - return $this->paths; - } - - /** - * Get the template for the endpoint. - * - * @return string - */ - protected function getTemplate() - { - return '// %s -$router->group([\'middleware\' => [%s], \'prefix\' => %s, \'where\' => [%s], \'domain\' => %s], function() use ($router) -{ - $router->resource(%s, %s, [\'only\' => [%s], \'names\' => [%s]]); -});'; - } - -} diff --git a/src/Illuminate/Routing/Annotations/ResourcePath.php b/src/Illuminate/Routing/Annotations/ResourcePath.php deleted file mode 100644 index 79ab24769e7..00000000000 --- a/src/Illuminate/Routing/Annotations/ResourcePath.php +++ /dev/null @@ -1,51 +0,0 @@ -method = $method; - $this->verb = $this->getVerb($method); - } - - /** - * Get the verb for the given resource method. - * - * @param string $method - * @return string - */ - protected function getVerb($method) - { - switch ($method) - { - case 'index': - case 'create': - case 'show': - case 'edit': - return 'get'; - - case 'store': - return 'post'; - - case 'update': - return 'put'; - - case 'destroy': - return 'delete'; - } - } - -} diff --git a/src/Illuminate/Routing/Annotations/Scanner.php b/src/Illuminate/Routing/Annotations/Scanner.php deleted file mode 100644 index e8ef23f663d..00000000000 --- a/src/Illuminate/Routing/Annotations/Scanner.php +++ /dev/null @@ -1,158 +0,0 @@ -scan = $scan; - - foreach (Finder::create()->files()->in(__DIR__.'/Annotations') as $file) - { - AnnotationRegistry::registerFile($file->getRealPath()); - } - } - - /** - * Create a new scanner instance. - * - * @param array $scan - * @return static - */ - public static function create(array $scan) - { - return new static($scan); - } - - /** - * Convert the scanned annotations into route definitions. - * - * @return string - */ - public function getRouteDefinitions() - { - $output = ''; - - foreach ($this->getEndpointsInClasses($this->getReader()) as $endpoint) - { - $output .= $endpoint->toRouteDefinition().PHP_EOL.PHP_EOL; - } - - return trim($output); - } - - /** - * Scan the directory and generate the route manifest. - * - * @param \Doctrine\Common\Annotations\SimpleAnnotationReader $reader - * @return \Illuminate\Routing\Annotations\EndpointCollection - */ - protected function getEndpointsInClasses(SimpleAnnotationReader $reader) - { - $endpoints = new EndpointCollection; - - foreach ($this->getClassesToScan() as $class) - { - $endpoints = $endpoints->merge($this->getEndpointsInClass( - $class, new AnnotationSet($class, $reader) - )); - } - - return $endpoints; - } - - /** - * Build the Endpoints for the given class. - * - * @param \ReflectionClass $class - * @param \Illuminate\Routing\Annotations\AnnotationSet $annotations - * @return \Illuminate\Routing\Annotations\EndpointCollection - */ - protected function getEndpointsInClass(ReflectionClass $class, AnnotationSet $annotations) - { - $endpoints = new EndpointCollection; - - foreach ($annotations->method as $method => $methodAnnotations) - $this->addEndpoint($endpoints, $class, $method, $methodAnnotations); - - foreach ($annotations->class as $annotation) - $annotation->modifyCollection($endpoints, $class); - - return $endpoints; - } - - /** - * Create a new endpoint in the collection. - * - * @param \Illuminate\Routing\Annotations\EndpointCollection $endpoints - * @param \ReflectionClass $class - * @param string $method - * @param array $annotations - * @return void - */ - protected function addEndpoint(EndpointCollection $endpoints, ReflectionClass $class, - $method, array $annotations) - { - $endpoints->push($endpoint = new MethodEndpoint([ - 'reflection' => $class, 'method' => $method, 'uses' => $class->name.'@'.$method - ])); - - foreach ($annotations as $annotation) - $annotation->modify($endpoint, $class->getMethod($method)); - } - - /** - * Get all of the ReflectionClass instances in the scan array. - * - * @return array - */ - protected function getClassesToScan() - { - $classes = []; - - foreach ($this->scan as $scan) - { - try - { - $classes[] = new ReflectionClass($scan); - } - catch (Exception $e) - { - // - } - } - - return $classes; - } - - /** - * Get an annotation reader instance. - * - * @return \Doctrine\Common\Annotations\SimpleAnnotationReader - */ - protected function getReader() - { - with($reader = new SimpleAnnotationReader) - ->addNamespace('Illuminate\Routing\Annotations\Annotations'); - - return $reader; - } - -} diff --git a/tests/Routing/RoutingAnnotationScannerTest.php b/tests/Routing/RoutingAnnotationScannerTest.php deleted file mode 100644 index 24b2d26a4cd..00000000000 --- a/tests/Routing/RoutingAnnotationScannerTest.php +++ /dev/null @@ -1,16 +0,0 @@ -getRouteDefinitions()); - - $this->assertEquals(trim(file_get_contents(__DIR__.'/results/annotation-basic.php')), $definition); - } - -} diff --git a/tests/Routing/results/annotation-basic.php b/tests/Routing/results/annotation-basic.php deleted file mode 100644 index 2b63ffebdd3..00000000000 --- a/tests/Routing/results/annotation-basic.php +++ /dev/null @@ -1,19 +0,0 @@ -$router->put('more/{id}', [ - 'uses' => 'App\Http\Controllers\BasicController@doMore', - 'as' => NULL, - 'middleware' => ['FooMiddleware', 'BarMiddleware', 'QuxMiddleware'], - 'where' => ['id' => 'regex'], - 'domain' => '{id}.account.com', -]); - -// Resource: foobar/photos@index -$router->group(['middleware' => ['FooMiddleware', 'BarMiddleware', 'BoomMiddleware', 'BazMiddleware'], 'prefix' => NULL, 'where' => ['id' => 'regex'], 'domain' => '{id}.account.com'], function() use ($router) -{ - $router->resource('foobar/photos', 'App\\Http\\Controllers\\BasicController', ['only' => ['index'], 'names' => ['index' => 'index.name']]); -}); - -// Resource: foobar/photos@update -$router->group(['middleware' => ['FooMiddleware', 'BarMiddleware'], 'prefix' => NULL, 'where' => ['id' => 'regex'], 'domain' => '{id}.account.com'], function() use ($router) -{ - $router->resource('foobar/photos', 'App\\Http\\Controllers\\BasicController', ['only' => ['update'], 'names' => []]); -});