コード例 #1
0
ファイル: MethodEventTest.php プロジェクト: tebru/dynamo
 public function testGetAnnotationCollection()
 {
     $methodModel = Mockery::mock(MethodModel::class);
     $annotationCollection = Mockery::mock(AnnotationCollection::class);
     $event = new MethodEvent($methodModel, $annotationCollection);
     $this->assertInstanceOf(AnnotationCollection::class, $event->getAnnotationCollection());
 }
コード例 #2
0
 /**
  * Handler the event
  *
  * @param MethodEvent $event
  */
 public function __invoke(MethodEvent $event)
 {
     $methodModel = $event->getMethodModel();
     $annotations = $event->getAnnotationCollection();
     $methodBodyBuilder = $this->methodBodyBuilderFactory->make();
     $handlers = [$this->handlerFactory->baseUrl($methodModel, $methodBodyBuilder, $annotations), $this->handlerFactory->serializationContext($methodModel, $methodBodyBuilder, $annotations), $this->handlerFactory->requestUrl($methodModel, $methodBodyBuilder, $annotations), $this->handlerFactory->requestHeader($methodModel, $methodBodyBuilder, $annotations), $this->handlerFactory->requestBody($methodModel, $methodBodyBuilder, $annotations), $this->handlerFactory->returns($methodModel, $methodBodyBuilder, $annotations)];
     /** @var Handler $handler */
     foreach ($handlers as $handler) {
         $handler->handle();
     }
     $body = $methodBodyBuilder->build();
     $methodModel->setBody($body);
 }
コード例 #3
0
 /**
  * Handle the event
  *
  * @param MethodEvent $event
  */
 public function __invoke(MethodEvent $event)
 {
     $methodModel = $event->getMethodModel();
     $annotations = $event->getAnnotationCollection();
     $annotationProvider = new AnnotationProvider($annotations, $methodModel);
     $body = new Body();
     $stack = new HandlerStack(new HandlerContext($annotationProvider, $body, new ArrayPrinter()));
     $stack->push(new UrlHandler());
     $stack->push(new HeaderHandler());
     $stack->push(new BodyHandler());
     $stack->push(new ResponseHandler());
     $stack->push(new ReturnHandler());
     $stack->execute();
     $methodModel->setBody($body);
 }