src/RawPHP/RawRouter/Controller.php
public function loadView( $data = [ ], $return = FALSE )
    {
        $retVal = NULL;
        //$extraData = $this->filter( self::ON_LOAD_EXTRA_DATA_FILTER, [ ] );

        $extra = [
            'route' => $this->_getRoute(),
        ];

        extract( $extra, EXTR_OVERWRITE );
        //extract( $extraData, EXTR_OVERWRITE );
        extract( $data, EXTR_OVERWRITE );

        $level = error_reporting();
        error_reporting( 0 );

        ob_start();

        if ( isset( $view ) )
        {
            $viewsDirEvent = new GetViewsDirEvent();

            $this->dispatcher->fire( Events::EVENT_GET_VIEWS_DIR, $viewsDirEvent );

            $viewDir = $viewsDirEvent->getViewsDir();

            if ( NULL === $viewDir )
            {
                throw new RawException( 'The views directory has not been set.' );
            }

            if ( FALSE !== strstr( $view, '.php' ) )
            {
                include $viewDir . $view;
            }
            else
            {
                include $viewDir . $view . '.php';
            }

            $newView = ob_get_clean();

            if ( $return )
            {
                $retVal = $newView;
            }
            else
            {
                $this->pageView .= $newView;
            }
        }
        else
        {
            $retVal = '';
        }

        error_reporting( $level );

        return $retVal;
    }
public function loadView( $data = [ ], $return = FALSE )
    {
        $retVal = NULL;
        //$extraData = $this->filter( self::ON_LOAD_EXTRA_DATA_FILTER, [ ] );

        $extra = [
            'route' => $this->_getRoute(),
        ];

        extract( $extra, EXTR_OVERWRITE );
        //extract( $extraData, EXTR_OVERWRITE );
        extract( $data, EXTR_OVERWRITE );

        $level = error_reporting();
        error_reporting( 0 );

        ob_start();

        if ( isset( $view ) )
        {
            $viewsDirEvent = new GetViewsDirEvent();

            $this->dispatcher->fire( Events::EVENT_GET_VIEWS_DIR, $viewsDirEvent );

            $viewDir = $viewsDirEvent->getViewsDir();

            if ( NULL === $viewDir )
            {
                throw new RawException( 'The views directory has not been set.' );
            }

            if ( FALSE !== strstr( $view, '.php' ) )
            {
                include $viewDir . $view;
            }
            else
            {
                include $viewDir . $view . '.php';
            }

            $newView = ob_get_clean();

            if ( $return )
            {
                $retVal = $newView;
            }
            else
            {
                $this->pageView .= $newView;
            }
        }
        else
        {
            $retVal = '';
        }

        error_reporting( $level );

        return $retVal;
    }
public function loadView ( $ data = [ ] , $ return = FALSE ) { $ retVal = NULL ; //$extraData = $this->filter( self::ON_LOAD_EXTRA_DATA_FILTER, [ ] ); $ extra = [ 'route' => $ this -> _getRoute ( ) , ] ; extract ( $ extra , EXTR_OVERWRITE ) ; //extract( $extraData, EXTR_OVERWRITE ); extract ( $ data , EXTR_OVERWRITE ) ; $ level = error_reporting ( ) ; error_reporting ( 0 ) ; ob_start ( ) ; if ( isset ( $ view ) ) { $ viewsDirEvent = new GetViewsDirEvent ( ) ; $ this -> dispatcher -> fire ( Events :: EVENT_GET_VIEWS_DIR , $ viewsDirEvent ) ; $ viewDir = $ viewsDirEvent -> getViewsDir ( ) ; if ( NULL === $ viewDir ) { throw new RawException ( 'The views directory has not been set.' ) ; } if ( FALSE !== strstr ( $ view , '.php' ) ) { include $ viewDir . $ view ; } else { include $ viewDir . $ view . '.php' ; } $ newView = ob_get_clean ( ) ; if ( $ return ) { $ retVal = $ newView ; } else { $ this -> pageView .= $ newView ; } } else { $ retVal = '' ; } error_reporting ( $ level ) ; return $ retVal ; }
Loads a view file.

This method requires Controller::ON_GET_VIEWS_DIR_FILTER to have
a valid callback assigned to the path of the view files.

@param array $data   data to make available to the views as variables
@param bool  $return whether to return the view to the calling method

@return mixed view html string on success, FALSE on error

@throws RawException if there is something wrong.
Loads a view file .