public function on($method, $path, $handler, $name = '') {
		if (!$this->result->hasHandler()
			&& $this->prefixMatched
			&& $this->request->isMethod($method)
		) {
			if ($this->matchPartial($path, true)) {
				$handlers = (array)$handler;

				if ($this->namespace) {
					foreach ($handlers as &$handler) {
						$handler = $this->namespace . $handler;
					}
				}

				if ($this->middlewares) {
					$handlers = array_merge($this->middlewares, $handlers);
				}

				$this->result->setHandler($handlers);
				$this->result->setStatus(200);
				$this->result->setParams($this->params);
			}
		}

		if ($name) {
			$this->urlGenerator->add($name, $this->prefix . $path);
		}

		return $this;
	}
public function on($method, $path, $handler, $name = '') {
		if (!$this->result->hasHandler()
			&& $this->prefixMatched
			&& $this->request->isMethod($method)
		) {
			if ($this->matchPartial($path, true)) {
				$handlers = (array)$handler;

				if ($this->namespace) {
					foreach ($handlers as &$handler) {
						$handler = $this->namespace . $handler;
					}
				}

				if ($this->middlewares) {
					$handlers = array_merge($this->middlewares, $handlers);
				}

				$this->result->setHandler($handlers);
				$this->result->setStatus(200);
				$this->result->setParams($this->params);
			}
		}

		if ($name) {
			$this->urlGenerator->add($name, $this->prefix . $path);
		}

		return $this;
	}
public function on ( $ method , $ path , $ handler , $ name = '' ) { if ( ! $ this -> result -> hasHandler ( ) && $ this -> prefixMatched && $ this -> request -> isMethod ( $ method ) ) { if ( $ this -> matchPartial ( $ path , true ) ) { $ handlers = ( array ) $ handler ; if ( $ this -> namespace ) { foreach ( $ handlers as & $ handler ) { $ handler = $ this -> namespace . $ handler ; } } if ( $ this -> middlewares ) { $ handlers = array_merge ( $ this -> middlewares , $ handlers ) ; } $ this -> result -> setHandler ( $ handlers ) ; $ this -> result -> setStatus ( 200 ) ; $ this -> result -> setParams ( $ this -> params ) ; } } if ( $ name ) { $ this -> urlGenerator -> add ( $ name , $ this -> prefix . $ path ) ; } return $ this ; }
Add a route.

@param string $method
@param string $path
@param string|string[] $handler
@param string $name Route name.
@return self
Add a route .