Universeorange.com/Docs/

R3m/framework Add controller

Add a controller in:

/project_dir/Host/<subdomain>/<hostname>/<extension>/Docs/Controller/Page.class

<?php
namespace Host\<subdomain>\<hostname>}\<extension>\Docs\Controller;

use R3m\Io\App;
use R3m\Io\Module\View;

use R3m\Io\Exception\LocateException;
use R3m\Io\Exception\UrlEmptyException;
use R3m\Io\Exception\UrlNotExistException;

class Page extends View {
    const DIR = __DIR__ . DIRECTORY_SEPARATOR;    

    public static function get(App $object){
        //$page = $object->request('page');
        //$extra = $object->request('extra');        
        $name = Page::name(__FUNCTION__); 
        try {
            if($object->data(App::CONTENT_TYPE) == App::CONTENT_TYPE_HTML){
                $url = Page::locate($object, 'Main');
                $object->data('template.name', $name);
                $object->data('template.dir', Page::DIR);
                $view = Page::response($object, $url);            
            } else {
                $url = Page::locate($object, $name);
                $view = Page::response($object, $url);
            }            
            return $view;
        } catch (Exception | LocateException | UrlEmptyException | UrlNotExistException $exception){
            return $exception->getMessage() . "\n";
        }
    }
}

Next: Create the view

Last modified: 2021-06-07

© 2021 universeorange.com