public function onMapRequest()
 {
     $c = \PMVC\plug('controller');
     $b = new \PMVC\MappingBuilder();
     $b->addForward('dump', [_TYPE => 'view']);
     $b->addForward('debug', [_TYPE => 'view']);
     $b->addForward('error', [_TYPE => 'redirect', _PATH => $this['realUrl'] . '/error']);
     $c->addMapping($b);
 }
예제 #2
0
 function setup()
 {
     $c = \PMVC\plug('controller', [_VIEW_ENGINE => 'json']);
     $b = new \PMVC\MappingBuilder();
     $b->addForward('debug', [_TYPE => 'view']);
     $c->addMapping($b);
     \PMVC\option('set', _TEMPLATE_DIR, './');
     $view = \PMVC\plug('view', [_CLASS => __NAMESPACE__ . '\\FakeView']);
 }
 public function testProcessError()
 {
     $b = new PMVC\MappingBuilder();
     $b->addAction('index', [_FUNCTION => ['FakeClass', 'index'], _FORM => 'FakeFailForm']);
     $b->addForward('error', [_PATH => 'hello', _TYPE => 'view']);
     $options = [\PMVC\ERRORS => [\PMVC\USER_ERRORS => 'erros', \PMVC\USER_LAST_ERROR => 'last'], _RUN_ACTION => 'index'];
     $mvc = \PMVC\plug('controller');
     \PMVC\set($mvc, $options);
     $view = \PMVC\plug('view', [_CLASS => '\\PMVC\\FakeView']);
     $error = $mvc->process($b);
     $this->assertEquals($options[\PMVC\ERRORS][\PMVC\USER_ERRORS], $error[0]['v']['errors']);
     $this->assertEquals($options[\PMVC\ERRORS][\PMVC\USER_LAST_ERROR], $error[0]['v']['lastError']);
 }
예제 #4
0
<?php

$b = new PMVC\MappingBuilder();
${_INIT_CONFIG}[_CLASS] = 'SwaggerUiAction';
${_INIT_CONFIG}[_INIT_BUILDER] = $b;
$b->addAction('index', [${_INIT_CONFIG}[_CLASS], 'index']);
$b->addAction('css', [${_INIT_CONFIG}[_CLASS], 'asset']);
$b->addAction('lib', [${_INIT_CONFIG}[_CLASS], 'asset']);
$b->addAction('swagger-ui.min.js', [${_INIT_CONFIG}[_CLASS], 'asset']);
$b->addAction('fonts', [${_INIT_CONFIG}[_CLASS], 'asset']);
$b->addAction('images', [${_INIT_CONFIG}[_CLASS], 'asset']);
$b->addForward('home', array(_PATH => 'index', _TYPE => 'view'));
\PMVC\getC()->store([_TEMPLATE_DIR => __DIR__ . '/themes/', _VIEW_ENGINE => "html"]);
class SwaggerUiAction extends PMVC\Action
{
    static function index($m, $f)
    {
        $go = $m['home'];
        return $go;
    }
    static function asset($m, $f)
    {
        $url = \PMVC\plug('url');
        $c = \PMVC\getC();
        $app = $c->getApp();
        $pathInfo = $url->getPathInfo();
        $path = str_replace('/' . $app . '/', '', $pathInfo);
        $asset = __DIR__ . '/' . 'themes/asset/' . $path;
        $fs = \PMVC\plug('file_list');
        $fs->dump($asset);
    }
예제 #5
0
<?php

$b = new PMVC\MappingBuilder();
${_INIT_CONFIG}[_CLASS] = 'NewActionName';
${_INIT_CONFIG}[_INIT_BUILDER] = $b;
$b->addAction('index', array(_FUNCTION => array(${_INIT_CONFIG}[_CLASS], 'index'), _FORM => 'HelloVerify'));
$b->addAction('lazy-index', array(_FUNCTION => array(${_INIT_CONFIG}[_CLASS], 'index_laziness')));
$b->addForward('home', array(_PATH => 'hello', _TYPE => 'view', _ACTION => 'lazy-index'));
$b->addForward('laze', array(_PATH => 'laze', _TYPE => 'view'));
class NewActionName extends PMVC\Action
{
    static function index($m, $f)
    {
        $go = $m['home'];
        $go->set('text', ' world---' . microtime());
        return $go;
    }
    static function index_laziness($m, $f)
    {
        $go = $m['laze'];
        $go->set('laze_text', 'This is laziness');
        return $go;
    }
}
class HelloVerify extends PMVC\ActionForm
{
    function validate()
    {
        //PMVC\plug("adkjfa;lsdkjf");
        return true;
    }