Dumplie\SharedKernel\Application\Command\ExtensionRegistry::pre PHP Method

pre() public method

public pre ( Command $command )
$command Command
    public function pre(Command $command)
    {
        foreach ($this->extensions as $extensionItem) {
            $extension = $extensionItem[self::EXTENSION_KEY];
            if ($extension->expands($command)) {
                $extension->pre($command, $this->serviceLocator);
            }
        }
    }

Usage Example

Example #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);
 }
All Usage Examples Of Dumplie\SharedKernel\Application\Command\ExtensionRegistry::pre