src/Core/Controller/AbstractController.php
public function hmvc($task, $input = null, $package = null)
    {
        // If task is controller object, just execute it.
        if ($task instanceof AbstractController) {
            if (is_array($input)) {
                $input = new Input($input);
            }

            // Let's push some important data into it.
            /** @var AbstractController $controller */
            $controller = $task->setContainer($this->container)
                ->isHmvc(true)
                ->setRequest($this->request)
                ->setResponse($this->response)
                ->setPackage($this->package)
                ->setApplication($this->package->app)
                ->setInput($input);

            // Do action and return executed result.
            $result = $controller->execute();

            // Take back the redirect information.
            $this->passRedirect($controller);

            return $result;
        }

        // If task is string, find controller by package
        $package = $package ? $this->app->getPackage($package) : $this->package;

        $response = $package->execute(
            $package->getController($task, $input),
            $this->getRequest(),
            new Response(),
            true
        );

        // Take back the redirect information.
        $this->passRedirect($package->getCurrentController());

        return $response->getBody()->__toString();
    }
public function hmvc($task, $input = null, $package = null)
    {
        // If task is controller object, just execute it.
        if ($task instanceof AbstractController) {
            if (is_array($input)) {
                $input = new Input($input);
            }

            // Let's push some important data into it.
            /** @var AbstractController $controller */
            $controller = $task->setContainer($this->container)
                ->isHmvc(true)
                ->setRequest($this->request)
                ->setResponse($this->response)
                ->setPackage($this->package)
                ->setApplication($this->package->app)
                ->setInput($input);

            // Do action and return executed result.
            $result = $controller->execute();

            // Take back the redirect information.
            $this->passRedirect($controller);

            return $result;
        }

        // If task is string, find controller by package
        $package = $package ? $this->app->getPackage($package) : $this->package;

        $response = $package->execute(
            $package->getController($task, $input),
            $this->getRequest(),
            new Response(),
            true
        );

        // Take back the redirect information.
        $this->passRedirect($package->getCurrentController());

        return $response->getBody()->__toString();
    }
public function hmvc ( $ task , $ input = null , $ package = null ) { // If task is controller object, just execute it. if ( $ task instanceof AbstractController ) { if ( is_array ( $ input ) ) { $ input = new Input ( $ input ) ; } // Let's push some important data into it. /** @var AbstractController $controller */ $ controller = $ task -> setContainer ( $ this -> container ) -> isHmvc ( true ) -> setRequest ( $ this -> request ) -> setResponse ( $ this -> response ) -> setPackage ( $ this -> package ) -> setApplication ( $ this -> package -> app ) -> setInput ( $ input ) ; // Do action and return executed result. $ result = $ controller -> execute ( ) ; // Take back the redirect information. $ this -> passRedirect ( $ controller ) ; return $ result ; } // If task is string, find controller by package $ package = $ package ? $ this -> app -> getPackage ( $ package ) : $ this -> package ; $ response = $ package -> execute ( $ package -> getController ( $ task , $ input ) , $ this -> getRequest ( ) , new Response ( ) , true ) ; // Take back the redirect information. $ this -> passRedirect ( $ package -> getCurrentController ( ) ) ; return $ response -> getBody ( ) -> __toString ( ) ; }
Run HMVC to fetch content from other controller.

@param string|AbstractController $task    The task to exeiocute, must be controller object or string.
The string format is `Name\ActionController`
example: `Page\GetController`
@param Input|array               $input   The input for this task, can be array or Input object.
@param string                    $package The package for this controller, can be string or AbstractPackage.

@return mixed
@throws \Throwable
Run HMVC to fetch content from other controller .