pre() публичный Метод

public pre ( Command $command )
$command Command
Пример #1
0
 public function test_extensions_execution_order()
 {
     $command = new CreateCart((string) CartId::generate(), 'PLN');
     $executionOrder = [];
     $prePromise = function () use(&$executionOrder) {
         $executionOrder[] = spl_object_hash($this);
     };
     $extension1 = $this->createExtensionProphecy($command, $prePromise);
     $extension2 = $this->createExtensionProphecy($command, $prePromise);
     $this->extensionRegistry->register($extension1->reveal(), 0);
     $this->extensionRegistry->register($extension2->reveal(), 1);
     $this->extensionRegistry->pre($command);
     $this->assertEquals([spl_object_hash($extension2), spl_object_hash($extension1)], $executionOrder);
 }
Пример #2
0
 /**
  * @param object $command
  * @param callable $next
  */
 public function execute($command, callable $next)
 {
     if ($command instanceof Command) {
         $this->extensionRegistry->pre($command);
     }
     try {
         $next($command);
     } catch (\Exception $exception) {
         $this->extensionRegistry->passException($command, $exception);
         throw $exception;
     }
     if ($command instanceof Command) {
         $this->extensionRegistry->post($command);
     }
 }