public function fetchRoutes($class) {
		$routes = [];

		$reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader();
		$reader->addNamespace('Asgard\Http\Annotation');
		if($this->cache) {
			$reader = new \Doctrine\Common\Annotations\CachedReader(
				$reader,
				$this->cache,
				$this->debug
			);
		}

		$reflection = new \ReflectionClass($class);
		$prefix = $reader->getClassAnnotation($reflection, 'Asgard\Http\Annotation\Prefix');
		$prefix = $prefix !== null ? $prefix->value:'';

		foreach($reflection->getMethods() as $method) {
			if(!preg_match('/Action$/i', $method->getName()))
				continue;
			$routeAnnot = $reader->getMethodAnnotation($method, 'Asgard\Http\Annotation\Route');
			if($routeAnnot !== null) {
				$route = trim($prefix.'/'.$routeAnnot->value, '/');
				$routes[] = new Route(
					$route,
					$class,
					preg_replace('/Action$/i', '', $method->getName()),
					[
						'host' => $routeAnnot->host,
						'requirements' => $routeAnnot->requirements,
						'method' => $routeAnnot->method,
						'name'	=>	$routeAnnot->name
					]
				);
			}
		}

		return $routes;
	}
public function fetchRoutes($class) {
		$routes = [];

		$reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader();
		$reader->addNamespace('Asgard\Http\Annotation');
		if($this->cache) {
			$reader = new \Doctrine\Common\Annotations\CachedReader(
				$reader,
				$this->cache,
				$this->debug
			);
		}

		$reflection = new \ReflectionClass($class);
		$prefix = $reader->getClassAnnotation($reflection, 'Asgard\Http\Annotation\Prefix');
		$prefix = $prefix !== null ? $prefix->value:'';

		foreach($reflection->getMethods() as $method) {
			if(!preg_match('/Action$/i', $method->getName()))
				continue;
			$routeAnnot = $reader->getMethodAnnotation($method, 'Asgard\Http\Annotation\Route');
			if($routeAnnot !== null) {
				$route = trim($prefix.'/'.$routeAnnot->value, '/');
				$routes[] = new Route(
					$route,
					$class,
					preg_replace('/Action$/i', '', $method->getName()),
					[
						'host' => $routeAnnot->host,
						'requirements' => $routeAnnot->requirements,
						'method' => $routeAnnot->method,
						'name'	=>	$routeAnnot->name
					]
				);
			}
		}

		return $routes;
	}
public function fetchRoutes ( $ class ) { $ routes = [ ] ; $ reader = new \ Doctrine \ Common \ Annotations \ SimpleAnnotationReader ( ) ; $ reader -> addNamespace ( 'Asgard\Http\Annotation' ) ; if ( $ this -> cache ) { $ reader = new \ Doctrine \ Common \ Annotations \ CachedReader ( $ reader , $ this -> cache , $ this -> debug ) ; } $ reflection = new \ ReflectionClass ( $ class ) ; $ prefix = $ reader -> getClassAnnotation ( $ reflection , 'Asgard\Http\Annotation\Prefix' ) ; $ prefix = $ prefix !== null ? $ prefix -> value : '' ; foreach ( $ reflection -> getMethods ( ) as $ method ) { if ( ! preg_match ( '/Action$/i' , $ method -> getName ( ) ) ) continue ; $ routeAnnot = $ reader -> getMethodAnnotation ( $ method , 'Asgard\Http\Annotation\Route' ) ; if ( $ routeAnnot !== null ) { $ route = trim ( $ prefix . '/' . $ routeAnnot -> value , '/' ) ; $ routes [ ] = new Route ( $ route , $ class , preg_replace ( '/Action$/i' , '' , $ method -> getName ( ) ) , [ 'host' => $ routeAnnot -> host , 'requirements' => $ routeAnnot -> requirements , 'method' => $ routeAnnot -> method , 'name' => $ routeAnnot -> name ] ) ; } } return $ routes ; }
Return the routes of a controller.
@param string $class
@return array
Return the routes of a controller .