Exemplo n.º 1
0
namespace Nether;

use Nether;
use Exception;
///////////////////////////////////////////////////////////////////////////////
// library options ////////////////////////////////////////////////////////////
Option::Define(['surface-auto-capture' => true, 'surface-auto-stash' => 'surface', 'surface-auto-render' => true, 'surface-theme' => 'default', 'surface-theme-stack' => ['common'], 'surface-theme-style' => 'default', 'surface-title-brand' => true, 'surface-theme-root' => sprintf('%s/themes', rtrim(Option::Get('nether-web-root'), '/')), 'surface-theme-path' => sprintf('%s/themes', rtrim(Option::Get('nether-web-path'), '/'))]);
///////////////////////////////////////////////////////////////////////////////
// library ki event handlers //////////////////////////////////////////////////
Ki::Queue('avenue-redirect', function () {
    // if a redirect was requested shut down the automatic surface instance and
    // throw away whatever it already collected.
    if (!class_exists('Nether\\Stash')) {
        return;
    }
    $surface = Stash::Get(Option::Get('surface-auto-stash'));
    if ($surface && $surface instanceof Surface) {
        $surface->SetAutoRender(false)->Stop(false);
    }
    return;
}, true);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class Surface
{
    /*//
    this is the engine engine designed to make it easy to application output into
    page templates with ease. there is no template language, the templates are
    plain html with embedded php calls to the various surface methods. just in case
    you have forgotten, php *is* a templating language.
    
Exemplo n.º 2
0
<?php

namespace Nether;

use Nether;
////////////////
////////////////
if (class_exists('Nether\\Ki')) {
    Ki::Queue('nether-shutdown', function () {
        /*//
        on system shutdown run through all the objects stored in the stash and execute
        their Shutdown method if they have one. this will allow things to clean up and
        store anything last minute if they need it.
        //*/
        foreach (array_keys(Stash::$Instances) as $key) {
            if (method_exists(Stash::$Instances[$key], 'Shutdown')) {
                Stash::$Instances[$key]->Shutdown();
            }
        }
        return;
    });
}
////////////////
////////////////
final class Stash
{
    /*//
    a static singleton class for passing objects throughout the current instance of
    the application. the stash is designed to hold objects of importance that should
    only ever exist once (e.g. singletons).
    //*/