Exemple #1
0
 public function __construct($model = null)
 {
     parent::__construct();
     $this->data = new stdClass();
     $this->meta = new ControllerMeta();
     /*{ TODO Having an XDO should be optional not all app asks for an XDO*/
     if (!$this instanceof NoXDO) {
         $this->xdo = new ControllerXDO();
         if ($this->xdo->serialized()) {
             $this->xdo->unserialize();
         }
     } else {
         $this->xdo = new DummyXDO();
     }
     /*}*/
     /*{ TODO Save applies here too. not all app need a session Storage some wants to work real Stateless too*/
     if (!$this instanceof NoSession) {
         $this->session = new SessionXDO();
         if ($this->session->serialized()) {
             $this->session->unserialize();
         }
     } else {
         $this->session = new DummyXDO();
     }
     /**/
     $controllerName = get_class($this);
     if (!$this instanceof NoXDO) {
         $desc = new \ROM\BongXDODescriptor(\ROM\BongXDODescriptor::ControllerXDO, $controllerName, $this->xdo->sessionFilePath());
         \ROM\BongCurrentUserData::instance()->addXDO($desc);
     }
     $this->spiritEngine = EngineFactory::produce("SpiritEngine", array(&$this));
     $this->ctor();
 }
Exemple #2
0
 public function prepareEngine()
 {
     switch ($this->navigation->controllerExtension) {
         case 'json':
             $this->_engine = EngineFactory::produce('AppJSONServiceEngine');
             break;
         case 'xml':
             $this->_engine = EngineFactory::produce('AppXMLServiceEngine');
             break;
         case 'prop':
             $this->_engine = EngineFactory::produce('AppPropertyServiceEngine');
             break;
         case 'res':
             $this->_engine = EngineFactory::produce('AppResponseServiceEngine');
             break;
     }
     parent::prepareEngine();
 }
Exemple #3
0
<?php

class AppXMLServiceEngine extends ServiceEngine
{
    public function __construct()
    {
        parent::__construct(new MVCEngine(), new XMLDeliveryTrait());
    }
}
EngineFactory::register('AppXMLServiceEngine');
Exemple #4
0
        }
        //TODO throw Exception as Controller not Existing
        assert('/*Throw SpiritAbstractorNotFound Exception on path ' . $controller . ' */');
    }
    private function layout($spiritName, $methodName)
    {
        $layouts = array(Path::instance()->currentProject("*{$spiritName}.view.-{$methodName}.@layout.php"), Path::instance()->currentProject("*{$spiritName}.view.@layout.php"), Path::instance()->currentProject("*common.view.@layout.php"));
        foreach ($layouts as $layout) {
            if (file_exists($layout)) {
                return $layout;
            }
        }
        //TODO throw Exception as no Layout found Existing
        assert('/*Throw SpiritLayoutNotFound Exception*/');
        print_r($layouts);
    }
    private function coordinator($spiritName)
    {
        return Path::instance()->currentProject("*{$spiritName}.@coordinator.php");
    }
    public function &_spirits()
    {
        return $this->spirits;
    }
    public function &_instances()
    {
        return $this->instances;
    }
}
EngineFactory::register("SpiritEngine");
<?php

class SpiritJSONServiceEngine extends ServiceEngine
{
    public function __construct()
    {
        parent::__construct(new SpiritEngineProxy(), new JSONDeliveryTrait());
    }
}
EngineFactory::register('SpiritJSONServiceEngine');
Exemple #6
0
<?php

class SpiritXMLServiceEngine extends ServiceEngine
{
    public function __construct()
    {
        parent::__construct(new SpiritEngineProxy(), new XMLDeliveryTrait());
    }
}
EngineFactory::register('SpiritXMLServiceEngine');
<?php

class SpiritPropertyServiceEngine extends ServiceEngine
{
    public function __construct()
    {
        parent::__construct(new SpiritEngineProxy(), new PropertyDeliveryTrait());
    }
}
EngineFactory::register('SpiritPropertyServiceEngine');
Exemple #8
0
     * FIXME Exceptions Not Handled
     * \algo
     * $this->responceBuffer: The XSLT as String
     * $xdoPath: Path to XML DataObject
     * \endalgo
     * @param string $xdoPath
     */
    private function processXSLView($xdoPath)
    {
        $xdo = new DOMDocument();
        $xdo->load($xdoPath);
        $xslt = new DOMDocument();
        if (!@$xslt->loadXML($this->responseBuffer)) {
            //TODO Handle Exceptions
            echo $this->responseBuffer;
            assert("/*Response Malformed Not Parsable as XML TODO Throw Exception*/");
        }
        $transformer = new XSLTProcessor();
        if (!@$transformer->importStylesheet($xslt)) {
            //TODO Handle Exceptions
            echo $transformer->saveXML();
            assert("/*Response Not XSL TODO Throw Exception*/");
        }
        $responseXML = $transformer->transformToDoc($xdo);
        //Response as a DOMDocument
        $this->responseBuffer = $responseXML->saveHTML();
        //TODO will it be HTML or XML should be decided based upon Content Mime Type
    }
}
EngineFactory::register("MVCEngine");
Exemple #9
0
<?php

class AppJSONServiceEngine extends ServiceEngine
{
    public function __construct()
    {
        parent::__construct(new MVCEngine(), new JSONDeliveryTrait());
    }
}
EngineFactory::register('AppJSONServiceEngine');
Exemple #10
0
 public function __construct($engineName)
 {
     $this->navigation = new StdClass();
     $this->_engine = EngineFactory::produce($engineName);
 }
Exemple #11
0
<?php

class FSMEngine extends ContentEngine
{
    protected function validate()
    {
    }
    public function executeLogic()
    {
    }
    public function run()
    {
        $fsm = \FSM\Engine::parse('site');
        $path = Path::instance()->evaluate('common') . '/fsm.php';
        ob_start();
        require $path;
        $this->responseBuffer = ob_get_contents();
        ob_end_clean();
    }
}
EngineFactory::register("FSMEngine");
Exemple #12
0
 public function prepareEngine()
 {
     switch ($this->navigation->spiritExtension) {
         case 'json':
             $this->_engine = EngineFactory::produce('SpiritJSONServiceEngine');
             break;
         case 'xml':
             $this->_engine = EngineFactory::produce('SpiritXMLServiceEngine');
             break;
         case 'prop':
             $this->_engine = EngineFactory::produce('SpiritPropertyServiceEngine');
             break;
         case 'res':
             $this->_engine = EngineFactory::produce('SpiritResponseServiceEngine');
             break;
     }
     parent::prepareEngine();
 }
<?php

class AppResponseServiceEngine extends ServiceEngine
{
    public function __construct()
    {
        parent::__construct(new MVCEngine(), new ResponseDeliveryTrait());
    }
}
EngineFactory::register('AppResponseServiceEngine');
Exemple #14
0
                        case 'xslt':
                            http::contentType('text/xml+xslt');
                            break;
                        case 'scrap':
                            http::contentType('text/plain');
                            break;
                        default:
                    }
                    switch ($this->navigation->resourceType) {
                        case 'img':
                            $this->responseBuffer = file_get_contents($resourcePath);
                            break;
                        default:
                            ob_start();
                            require $resourcePath;
                            $this->responseBuffer = ob_get_contents();
                            ob_end_clean();
                    }
                } else {
                    throw new FileNotFoundException($resourcePath ? $resourcePath : 'null <Resource Path Could not be Resolved> ');
                }
            } else {
                throw new ProjectDirNotFoundException($this->projectName);
            }
        } else {
            throw new ProjectNotFoundException($this->projectName);
        }
    }
}
EngineFactory::register('ResourceEngine');
<?php

class SpiritResponseServiceEngine extends ServiceEngine
{
    public function __construct()
    {
        parent::__construct(new SpiritEngineProxy(), new ResponseDeliveryTrait());
    }
}
EngineFactory::register('SpiritResponseServiceEngine');