src/Helper.php
public static function loadInlineView($sViewFile, $aViewData = [], $bReturnView = false)
    {
        $aCtrlData   =& getControllerData();
        $sCtrlPath   = !empty($aCtrlData['currentRequest']['path']) ? $aCtrlData['currentRequest']['path'] : '';
        $sCtrlName   = basename($sCtrlPath, '.php');
        $aCtrlPath   = explode(DIRECTORY_SEPARATOR, $sCtrlPath);
        $aCtrlPath   = array_splice($aCtrlPath, 0, count($aCtrlPath) - 2);
        $aCtrlPath[] = 'views';
        $aCtrlPath[] = $sCtrlName;
        $aCtrlPath[] = $sViewFile;
        $sViewPath   = implode(DIRECTORY_SEPARATOR, $aCtrlPath) . '.php';

        $oView = Factory::service('View');

        //  Load the view
        try {
            return $oView->load($sViewPath, $aViewData, $bReturnView);
        } catch (ViewNotFoundException $e) {
            //  If it fails, and the controller is a default admin controller then load up that view
            $sClassName = $aCtrlData['currentRequest']['className'];
            if (!classExtends($sClassName, 'Nails\\Admin\\Controller\\DefaultController')) {
                throw new ViewNotFoundException(
                    $e->getMessage(),
                    $e->getCode()
                );
            }

            //  Step through the class hierarchy and look there
            $aParents = class_parents($sClassName);
            foreach ($aParents as $sParent) {
                try {

                    if ($sParent !== 'Nails\\Admin\\Controller\\DefaultController') {

                        $oReflection = new \ReflectionClass('\\' . $sParent);
                        $sViewPath   = realpath(dirname($oReflection->getFileName()) . '/../views') . '/';
                        $aClassBits  = explode('\\', $oReflection->getName());
                        $sViewPath   .= end($aClassBits) . '/';

                    } else {
                        $sViewPath     = 'admin/DefaultController/';
                        $bTriedDefault = true;
                    };

                    return $oView->load(
                        $sViewPath . $sViewFile,
                        $aViewData,
                        $bReturnView
                    );
                } catch (ViewNotFoundException $e) {
                    //  Allow the loop to continue, unless we've already tried the default views
                    if (!empty($bTriedDefault)) {
                        throw $e;
                    }
                }
            }
        }
    }
public static function loadInlineView($sViewFile, $aViewData = [], $bReturnView = false)
    {
        $aCtrlData   =& getControllerData();
        $sCtrlPath   = !empty($aCtrlData['currentRequest']['path']) ? $aCtrlData['currentRequest']['path'] : '';
        $sCtrlName   = basename($sCtrlPath, '.php');
        $aCtrlPath   = explode(DIRECTORY_SEPARATOR, $sCtrlPath);
        $aCtrlPath   = array_splice($aCtrlPath, 0, count($aCtrlPath) - 2);
        $aCtrlPath[] = 'views';
        $aCtrlPath[] = $sCtrlName;
        $aCtrlPath[] = $sViewFile;
        $sViewPath   = implode(DIRECTORY_SEPARATOR, $aCtrlPath) . '.php';

        $oView = Factory::service('View');

        //  Load the view
        try {
            return $oView->load($sViewPath, $aViewData, $bReturnView);
        } catch (ViewNotFoundException $e) {
            //  If it fails, and the controller is a default admin controller then load up that view
            $sClassName = $aCtrlData['currentRequest']['className'];
            if (!classExtends($sClassName, 'Nails\\Admin\\Controller\\DefaultController')) {
                throw new ViewNotFoundException(
                    $e->getMessage(),
                    $e->getCode()
                );
            }

            //  Step through the class hierarchy and look there
            $aParents = class_parents($sClassName);
            foreach ($aParents as $sParent) {
                try {

                    if ($sParent !== 'Nails\\Admin\\Controller\\DefaultController') {

                        $oReflection = new \ReflectionClass('\\' . $sParent);
                        $sViewPath   = realpath(dirname($oReflection->getFileName()) . '/../views') . '/';
                        $aClassBits  = explode('\\', $oReflection->getName());
                        $sViewPath   .= end($aClassBits) . '/';

                    } else {
                        $sViewPath     = 'admin/DefaultController/';
                        $bTriedDefault = true;
                    };

                    return $oView->load(
                        $sViewPath . $sViewFile,
                        $aViewData,
                        $bReturnView
                    );
                } catch (ViewNotFoundException $e) {
                    //  Allow the loop to continue, unless we've already tried the default views
                    if (!empty($bTriedDefault)) {
                        throw $e;
                    }
                }
            }
        }
    }
Load a single view taking into account the module being accessed.

@param  string  $sViewFile   The view to load
@param  array   $aViewData   The data to pass to the view
@param  boolean $bReturnView Whether to return the view or send it to the Output class

@throws \Exception

@return mixed               String when $bReturnView is true, void otherwise