Пример #1
0
 /**
  * If appropriate, validate query data.
  *
  * @param $query
  */
 protected function validateQuery($query)
 {
     $validator = $this->queryTranslator->toValidator($query);
     if (class_exists($validator)) {
         $this->app->make($validator)->validate($query);
     }
 }
 function it_handles_command_if_validation_succeeds(Application $application, QueryTranslator $translator, QueryBus $bus, ExampleQuery $query, ExampleValidator $validator)
 {
     // Own responsibility
     $translator->toValidator($query)->willReturn(ExampleValidator::class);
     $application->make(ExampleValidator::class)->willReturn($validator);
     // Delegated responsibility
     $bus->executeQuery($query)->shouldBeCalled();
     $this->executeQuery($query);
 }
Пример #3
0
 /**
  * Execute the query
  *
  * @param $query
  *
  * @return mixed
  */
 public function executeQuery($query)
 {
     $this->executeDecorators($query);
     $handler = $this->queryTranslator->toQueryHandler($query);
     return $this->app->make($handler)->handle($query);
 }