src/services/Router.php
public function getCall($route, array $params = [])
		{
			// variables
			$route      = AbstractScanner::folderize($route);
			$routes     = $this->getRoutes();

			// debug
			// pr($route, $routes);

			// first, attempt to find an exact match
			// an exact match will either be a controller or a folder
			if(isset($routes[$route]))
			{
				return $routes[$route];
			}

			// otherwise, the passed path will be at least a "controller/method" in which case,
            // we need to find the nearest partial match, then extract the component parts
			else
			{
				// variables
				/** @var CallReference $ref */
				$ref    = null;

				// loop over routes and grab matches
				// the last full match will be the one that we want
				foreach($routes as $key => $value)
				{
					//pr('KEY', $key, $value);
					if(strpos($route, $key) === 0)
					{
						$ref        = $value;
					}
				}

				// debug
				//pr('REF', $ref);

				// if we got a matching route, update the ref with method and params
				if($ref instanceof ControllerReference)
                {
                    return CallReference::fromControllerRef($ref)
	                    ->setMethod($route)
	                    ->setParams($params);
				}

				if($ref instanceof ControllerErrorReference)
                {
                    return CallReference::fromRef($ref)
	                    ->setMethod($route)
	                    ->setParams($params);
				}

			}

			// return
			return null;
		}
public function getCall($route, array $params = [])
		{
			// variables
			$route      = AbstractScanner::folderize($route);
			$routes     = $this->getRoutes();

			// debug
			// pr($route, $routes);

			// first, attempt to find an exact match
			// an exact match will either be a controller or a folder
			if(isset($routes[$route]))
			{
				return $routes[$route];
			}

			// otherwise, the passed path will be at least a "controller/method" in which case,
            // we need to find the nearest partial match, then extract the component parts
			else
			{
				// variables
				/** @var CallReference $ref */
				$ref    = null;

				// loop over routes and grab matches
				// the last full match will be the one that we want
				foreach($routes as $key => $value)
				{
					//pr('KEY', $key, $value);
					if(strpos($route, $key) === 0)
					{
						$ref        = $value;
					}
				}

				// debug
				//pr('REF', $ref);

				// if we got a matching route, update the ref with method and params
				if($ref instanceof ControllerReference)
                {
                    return CallReference::fromControllerRef($ref)
	                    ->setMethod($route)
	                    ->setParams($params);
				}

				if($ref instanceof ControllerErrorReference)
                {
                    return CallReference::fromRef($ref)
	                    ->setMethod($route)
	                    ->setParams($params);
				}

			}

			// return
			return null;
		}
public function getCall ( $ route , array $ params = [ ] ) { // variables $ route = AbstractScanner :: folderize ( $ route ) ; $ routes = $ this -> getRoutes ( ) ; // debug // pr($route, $routes); // first, attempt to find an exact match // an exact match will either be a controller or a folder if ( isset ( $ routes [ $ route ] ) ) { return $ routes [ $ route ] ; } // otherwise, the passed path will be at least a "controller/method" in which case, // we need to find the nearest partial match, then extract the component parts else { // variables /** @var CallReference $ref */ $ ref = null ; // loop over routes and grab matches // the last full match will be the one that we want foreach ( $ routes as $ key => $ value ) { //pr('KEY', $key, $value); if ( strpos ( $ route , $ key ) === 0 ) { $ ref = $ value ; } } // debug //pr('REF', $ref); // if we got a matching route, update the ref with method and params if ( $ ref instanceof ControllerReference ) { return CallReference :: fromControllerRef ( $ ref ) -> setMethod ( $ route ) -> setParams ( $ params ) ; } if ( $ ref instanceof ControllerErrorReference ) { return CallReference :: fromRef ( $ ref ) -> setMethod ( $ route ) -> setParams ( $ params ) ; } } // return return null ; }
Reverse route lookup

Compares a given route against routes determined when controllers were scanned

Determines the controller, method and parameters to call if there is a match

@param   string $route
@param $params
@return ControllerReference|FolderReference|null
Reverse route lookup