src/mako/http/routing/Dispatcher.php
protected function executeController(string $controller, array $parameters): Response
	{
		if(strpos($controller, '::') === false)
		{
			$method = '__invoke';
		}
		else
		{
			[$controller, $method] = explode('::', $controller, 2);
		}

		$controller = $this->container->get($controller);

		// Execute the before action method if we have one

		if(method_exists($controller, 'beforeAction'))
		{
			$returnValue = $this->container->call([$controller, 'beforeAction']);
		}

		if(empty($returnValue))
		{
			// The before action method didn't return any data so we can set the
			// response body to whatever the route action returns

			$this->response->setBody($this->container->call([$controller, $method], $parameters));

			// Execute the after action method if we have one

			if(method_exists($controller, 'afterAction'))
			{
				$this->container->call([$controller, 'afterAction']);
			}
		}
		else
		{
			// The before action method returned data so we'll set the response body to whatever it returned

			$this->response->setBody($returnValue);
		}

		return $this->response;
	}
protected function executeController(string $controller, array $parameters): Response
	{
		if(strpos($controller, '::') === false)
		{
			$method = '__invoke';
		}
		else
		{
			[$controller, $method] = explode('::', $controller, 2);
		}

		$controller = $this->container->get($controller);

		// Execute the before action method if we have one

		if(method_exists($controller, 'beforeAction'))
		{
			$returnValue = $this->container->call([$controller, 'beforeAction']);
		}

		if(empty($returnValue))
		{
			// The before action method didn't return any data so we can set the
			// response body to whatever the route action returns

			$this->response->setBody($this->container->call([$controller, $method], $parameters));

			// Execute the after action method if we have one

			if(method_exists($controller, 'afterAction'))
			{
				$this->container->call([$controller, 'afterAction']);
			}
		}
		else
		{
			// The before action method returned data so we'll set the response body to whatever it returned

			$this->response->setBody($returnValue);
		}

		return $this->response;
	}
protected function executeController ( string $ controller , array $ parameters ) : Response { if ( strpos ( $ controller , '::' ) === false ) { $ method = '__invoke' ; } else { [ $ controller , $ method ] = explode ( '::' , $ controller , 2 ) ; } $ controller = $ this -> container -> get ( $ controller ) ; // Execute the before action method if we have one if ( method_exists ( $ controller , 'beforeAction' ) ) { $ returnValue = $ this -> container -> call ( [ $ controller , 'beforeAction' ] ) ; } if ( empty ( $ returnValue ) ) { // The before action method didn't return any data so we can set the // response body to whatever the route action returns $ this -> response -> setBody ( $ this -> container -> call ( [ $ controller , $ method ] , $ parameters ) ) ; // Execute the after action method if we have one if ( method_exists ( $ controller , 'afterAction' ) ) { $ this -> container -> call ( [ $ controller , 'afterAction' ] ) ; } } else { // The before action method returned data so we'll set the response body to whatever it returned $ this -> response -> setBody ( $ returnValue ) ; } return $ this -> response ; }
Executes a controller action.

@param  string              $controller Controller
@param  array               $parameters Parameters
@return \mako\http\Response
Executes a controller action .