@@ -6,7 +6,6 @@ |
||
| 6 | 6 | use Illuminate\Database\QueryException; |
| 7 | 7 | use SmoothPhp\Contracts\Domain\DomainEventStream; |
| 8 | 8 | use SmoothPhp\Contracts\Domain\DomainMessage; |
| 9 | -use SmoothPhp\Contracts\EventStore\DomainEventStreamInterface; |
|
| 10 | 9 | use SmoothPhp\Contracts\EventStore\EventStore; |
| 11 | 10 | use SmoothPhp\Contracts\EventStore\EventStreamNotFound; |
| 12 | 11 | use SmoothPhp\Contracts\Serialization\Serializer; |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | public function load($id) |
| 54 | 54 | { |
| 55 | 55 | $rows = $this->db->table($this->eventStoreTableName) |
| 56 | - ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
| 57 | - ->where('uuid', $id) |
|
| 58 | - ->orderBy('playhead', 'asc') |
|
| 59 | - ->get(); |
|
| 56 | + ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
| 57 | + ->where('uuid', $id) |
|
| 58 | + ->orderBy('playhead', 'asc') |
|
| 59 | + ->get(); |
|
| 60 | 60 | $events = []; |
| 61 | 61 | |
| 62 | 62 | foreach ($rows as $row) { |
@@ -103,16 +103,16 @@ discard block |
||
| 103 | 103 | private function insertEvent(DomainMessage $domainMessage) |
| 104 | 104 | { |
| 105 | 105 | $this->db->table($this->eventStoreTableName) |
| 106 | - ->insert( |
|
| 107 | - [ |
|
| 108 | - 'uuid' => (string)$domainMessage->getId(), |
|
| 109 | - 'playhead' => $domainMessage->getPlayHead(), |
|
| 110 | - 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
| 111 | - 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
| 112 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 113 | - 'type' => $domainMessage->getType(), |
|
| 114 | - ] |
|
| 115 | - ); |
|
| 106 | + ->insert( |
|
| 107 | + [ |
|
| 108 | + 'uuid' => (string)$domainMessage->getId(), |
|
| 109 | + 'playhead' => $domainMessage->getPlayHead(), |
|
| 110 | + 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
| 111 | + 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
| 112 | + 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 113 | + 'type' => $domainMessage->getType(), |
|
| 114 | + ] |
|
| 115 | + ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function append($id, DomainEventStream $eventStream) |
| 82 | 82 | { |
| 83 | - $id = (string)$id; //Used to thrown errors if ID will not cast to string |
|
| 83 | + $id = (string) $id; //Used to thrown errors if ID will not cast to string |
|
| 84 | 84 | |
| 85 | 85 | $this->db->beginTransaction(); |
| 86 | 86 | |
| 87 | 87 | try { |
| 88 | 88 | foreach ($eventStream as $domainMessage) { |
| 89 | - $this->insertEvent( $domainMessage); |
|
| 89 | + $this->insertEvent($domainMessage); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $this->db->commit(); |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | $this->db->table($this->eventStoreTableName) |
| 106 | 106 | ->insert( |
| 107 | 107 | [ |
| 108 | - 'uuid' => (string)$domainMessage->getId(), |
|
| 108 | + 'uuid' => (string) $domainMessage->getId(), |
|
| 109 | 109 | 'playhead' => $domainMessage->getPlayHead(), |
| 110 | 110 | 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
| 111 | 111 | 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
| 112 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 112 | + 'recorded_on' => (string) $domainMessage->getRecordedOn(), |
|
| 113 | 113 | 'type' => $domainMessage->getType(), |
| 114 | 114 | ] |
| 115 | 115 | ); |
@@ -121,9 +121,9 @@ |
||
| 121 | 121 | $app->bind(EventStore::class, |
| 122 | 122 | function (Application $application) { |
| 123 | 123 | return new LaravelEventStore($application->make(DatabaseManager::class), |
| 124 | - $application->make(Serializer::class), |
|
| 125 | - $application['config']->get('cqrses.eventstore_connection'), |
|
| 126 | - $application['config']->get('cqrses.eventstore_table') |
|
| 124 | + $application->make(Serializer::class), |
|
| 125 | + $application['config']->get('cqrses.eventstore_connection'), |
|
| 126 | + $application['config']->get('cqrses.eventstore_table') |
|
| 127 | 127 | ); |
| 128 | 128 | } |
| 129 | 129 | ); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | if ($app['config']->get('cqrses.command_bus_enabled')) { |
| 97 | 97 | $this->app->singleton(CommandBus::class, |
| 98 | - function (Application $application) { |
|
| 98 | + function(Application $application) { |
|
| 99 | 99 | return new SimpleCommandBus( |
| 100 | 100 | new SimpleCommandTranslator(), |
| 101 | 101 | $application->make(LaravelCommandBusHandlerResolver::class)); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | if ($app['config']->get('cqrses.laravel_eventstore_enabled')) { |
| 121 | 121 | $app->bind(EventStore::class, |
| 122 | - function (Application $application) { |
|
| 122 | + function(Application $application) { |
|
| 123 | 123 | return new LaravelEventStore($application->make(DatabaseManager::class), |
| 124 | 124 | $application->make(Serializer::class), |
| 125 | 125 | $application['config']->get('cqrses.eventstore_connection'), |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | protected function registerEventBus(Application $app) |
| 137 | 137 | { |
| 138 | 138 | $app->singleton(EventBus::class, |
| 139 | - function (Application $application) { |
|
| 139 | + function(Application $application) { |
|
| 140 | 140 | $eventBus = $application->make($application['config']->get('cqrses.event_bus')); |
| 141 | 141 | |
| 142 | 142 | foreach ($application['config']->get('cqrses.event_bus_listeners') as $listener) { |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | protected function registerEventDispatcher(Application $app) |
| 155 | 155 | { |
| 156 | 156 | $app->singleton(EventDispatcher::class, |
| 157 | - function (Application $application) { |
|
| 157 | + function(Application $application) { |
|
| 158 | 158 | return $application->make($application['config']->get('cqrses.event_dispatcher'), [false]); |
| 159 | 159 | } |
| 160 | 160 | ); |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | public function fire($job, $data) |
| 37 | 37 | { |
| 38 | - $payload = (json_decode($data['payload'],true)); |
|
| 38 | + $payload = (json_decode($data['payload'], true)); |
|
| 39 | 39 | |
| 40 | 40 | $event = call_user_func([ |
| 41 | 41 | str_replace('.', '\\', $data['type']), |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function handle(DomainMessage $domainMessage) |
| 31 | 31 | { |
| 32 | - $name = explode('.',$domainMessage->getType()); |
|
| 32 | + $name = explode('.', $domainMessage->getType()); |
|
| 33 | 33 | |
| 34 | 34 | $name = preg_replace('/(?!^)[A-Z]{2,}(?=[A-Z][a-z])|[A-Z][a-z]/', ' $0', end($name)); |
| 35 | 35 | $this->log->debug(trim(ucwords($name)) . " ({$domainMessage->getType()})"); |
@@ -37,13 +37,13 @@ |
||
| 37 | 37 | public function handle(DomainMessage $domainMessage) |
| 38 | 38 | { |
| 39 | 39 | $this->queue->push(QueueToEventDispatcher::class, |
| 40 | - [ |
|
| 41 | - 'uuid' => (string)$domainMessage->getId(), |
|
| 42 | - 'playhead' => $domainMessage->getPlayHead(), |
|
| 43 | - 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
| 44 | - 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
| 45 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 46 | - 'type' => $domainMessage->getType(), |
|
| 47 | - ]); |
|
| 40 | + [ |
|
| 41 | + 'uuid' => (string)$domainMessage->getId(), |
|
| 42 | + 'playhead' => $domainMessage->getPlayHead(), |
|
| 43 | + 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
|
| 44 | + 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
|
| 45 | + 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 46 | + 'type' => $domainMessage->getType(), |
|
| 47 | + ]); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -38,11 +38,11 @@ |
||
| 38 | 38 | { |
| 39 | 39 | $this->queue->push(QueueToEventDispatcher::class, |
| 40 | 40 | [ |
| 41 | - 'uuid' => (string)$domainMessage->getId(), |
|
| 41 | + 'uuid' => (string) $domainMessage->getId(), |
|
| 42 | 42 | 'playhead' => $domainMessage->getPlayHead(), |
| 43 | 43 | 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
| 44 | 44 | 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
| 45 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
| 45 | + 'recorded_on' => (string) $domainMessage->getRecordedOn(), |
|
| 46 | 46 | 'type' => $domainMessage->getType(), |
| 47 | 47 | ]); |
| 48 | 48 | } |
@@ -79,14 +79,14 @@ |
||
| 79 | 79 | */ |
| 80 | 80 | public function handle() |
| 81 | 81 | { |
| 82 | - foreach($this->config->get('cqrses.pre_rebuild_commands') as $preRebuildCommand) |
|
| 82 | + foreach ($this->config->get('cqrses.pre_rebuild_commands') as $preRebuildCommand) |
|
| 83 | 83 | { |
| 84 | 84 | $this->call($preRebuildCommand); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $this->replayEvents(); |
| 88 | 88 | |
| 89 | - foreach($this->config->get('cqrses.post_rebuild_commands') as $postRebuildCommand) |
|
| 89 | + foreach ($this->config->get('cqrses.post_rebuild_commands') as $postRebuildCommand) |
|
| 90 | 90 | { |
| 91 | 91 | $this->call($postRebuildCommand); |
| 92 | 92 | } |
@@ -57,16 +57,16 @@ |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | Schema::connection($this->config->get('cqrses.eventstore_connection')) |
| 60 | - ->create($this->config->get('cqrses.eventstore_table'), |
|
| 61 | - function (Blueprint $table) { |
|
| 62 | - $table->increments('id'); |
|
| 63 | - $table->string('uuid', 56); |
|
| 64 | - $table->integer('playhead')->unsigned(); |
|
| 65 | - $table->text('metadata'); |
|
| 66 | - $table->text('payload'); |
|
| 67 | - $table->string('recorded_on', 32); |
|
| 68 | - $table->text('type'); |
|
| 69 | - $table->unique(['uuid', 'playhead']); |
|
| 70 | - }); |
|
| 60 | + ->create($this->config->get('cqrses.eventstore_table'), |
|
| 61 | + function (Blueprint $table) { |
|
| 62 | + $table->increments('id'); |
|
| 63 | + $table->string('uuid', 56); |
|
| 64 | + $table->integer('playhead')->unsigned(); |
|
| 65 | + $table->text('metadata'); |
|
| 66 | + $table->text('payload'); |
|
| 67 | + $table->string('recorded_on', 32); |
|
| 68 | + $table->text('type'); |
|
| 69 | + $table->unique(['uuid', 'playhead']); |
|
| 70 | + }); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | \ No newline at end of file |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | |
| 59 | 59 | Schema::connection($this->config->get('cqrses.eventstore_connection')) |
| 60 | 60 | ->create($this->config->get('cqrses.eventstore_table'), |
| 61 | - function (Blueprint $table) { |
|
| 61 | + function(Blueprint $table) { |
|
| 62 | 62 | $table->increments('id'); |
| 63 | 63 | $table->string('uuid', 56); |
| 64 | 64 | $table->integer('playhead')->unsigned(); |
@@ -96,11 +96,11 @@ |
||
| 96 | 96 | $stub = file_get_contents($this->getStub()); |
| 97 | 97 | |
| 98 | 98 | $namespace = rtrim($this->config->get('cqrses.namespace') . $this->argument('aggregate') . '\\' . $this->getFolder(), |
| 99 | - '\\'); |
|
| 99 | + '\\'); |
|
| 100 | 100 | |
| 101 | 101 | $stub = $this->replaceStubVariable('namespace', |
| 102 | - $namespace, |
|
| 103 | - $stub); |
|
| 102 | + $namespace, |
|
| 103 | + $stub); |
|
| 104 | 104 | |
| 105 | 105 | foreach ($this->replacementVariables() as $variableName => $variableValue) { |
| 106 | 106 | $stub = $this->replaceStubVariable($variableName, $variableValue, $stub); |