Exemplo n.º 1
0
 public function serve($cycle = null, $flags = 0)
 {
     $cycle = $cycle ? $cycle : Cycle::create();
     $result = $this->dispatch($cycle->request()->getMethod(), $cycle->request()->getUri()->getPath(), $flags);
     if (!$result) {
         $w = $cycle(404, []);
         $w($cycle->request()->getUri());
         return $this->emit($cycle);
     }
     $plugins = $result['plugins'];
     $cycle->setMountPoint($result['mountpoint']);
     $cycle->setPathParameters($result['parameters']);
     $runner = $result['handler'];
     if (!is_callable($runner)) {
         //build method annotation plugins
         $plugins = array_merge($runner->buildPlugins($result['annotationPlugins'] + $this->getAnnotationPlugins()), $plugins);
         $runner = $runner->getCallable();
     }
     //build callable
     $callable = array_reduce(array_merge($plugins, $this->plugins), function ($carry, $item) {
         return $item($carry);
     }, $runner);
     $r = $callable($cycle);
     return $this->emit($cycle, $r);
 }
Exemplo n.º 2
0
 /**
  * @expectedException RuntimeException
  *
  */
 public function testPropSet()
 {
     $cycle = Cycle::create();
     $cycle->bar = 'bar';
 }