Exemplo n.º 1
0
 /**
  * 定义命令组对象并返回
  * 
  * @param  array   $list 指令集数组
  * 
  * @return \Ws\Mvc\CmdGroup
  */
 public static function group(array $list)
 {
     $ss = [];
     foreach ($list as $item) {
         if (!empty($item)) {
             $ss[] = Cmd::id($item['id'])->bind($item['event'], $item['closure']);
         }
     }
     return new CmdGroup($ss);
 }
Exemplo n.º 2
0
<?php

use Ws\Env;
use Ws\Mvc\Request;
use Ws\Mvc\Cmd;
$app = $this->me();
/*@var $app \Ws\Mvc\App */
$dir = $app->config()->get('app.dir');
// 注入类路径
Env::classLoader()->addPsr4('Im\\', $dir);
// 绑定命令
Cmd::id('index')->bind(Request::GET, function ($app) {
    output('App: ' . $app->config()->get('app.id'), '');
    output('Hello World!', 'text');
    output($app->pagePathing('who.are.you', ['name' => 'a test']), 'url');
    output($app->jsonPathing('who.love.you', ['tag' => 'php']), 'url');
})->bindTo($app);
Cmd::id('view')->bind(Request::GET, 'Im\\Controller\\Index@index')->bindTo($app);
Cmd::group([['id' => 'hello', 'event' => Request::GET, 'closure' => function ($a) {
    Env::dump($a);
}]])->bindTo($app);
// Env::dump($app);
Exemplo n.º 3
0
<?php

use Ws\Env;
use Ws\Mvc\Request;
use Ws\Mvc\Cmd;
$app = $this->me();
/*@var $app \Ws\Mvc\App */
$dir = $app->config()->get('app.dir');
// 注入类路径
Env::classLoader()->addPsr4('Default\\', $dir);
// 绑定命令
Cmd::id('index')->bind(Request::GET, function ($app) {
    output('App: ' . $app->config()->get('app.id'), '');
    output('Hello World!', 'text');
    output($app->pagePathing('who.are.you', ['name' => 'a test']), 'url');
    output($app->jsonPathing('who.love.you', ['tag' => 'php']), 'url');
})->bindTo($app);
Exemplo n.º 4
0
<?php

use Ws\Env;
use Ws\Mvc\Request;
use Ws\Mvc\Cmd;
$app = $this->me();
/*@var $app \Ws\Mvc\App */
$dir = $app->config()->get('app.dir');
// 注入类路径
Env::classLoader()->addPsr4('Blog\\', $dir);
// 绑定命令
Cmd::id('hello')->bind(Request::GET, function ($app) {
    output('App: ' . $app->config()->get('app.id'), '');
    output('Hello World!', 'text');
    output($app->pagePathing('who.are.you', ['name' => 'a test']), 'url');
    output($app->jsonPathing('who.love.you', ['tag' => 'php']), 'url');
})->bindTo($app);
Cmd::id('index')->bind(Request::GET, 'Blog\\Controller\\Index@index')->bindTo($app);
// Cmd::group([
// 		[
// 			'id'	=> 'hello',
// 			'event'	=> Request::GET,
// 			'closure'	=> function($a){
// 				Env::dump($a);
// 			}
// 		]
// 	])->bindTo($app);
// Env::dump($app);