@@ -163,8 +163,8 @@ For instance, in a `Interop\Container` compliant Service Container, we can do th
163
163
<?php
164
164
//...your other registered classes
165
165
166
- $container['RegisterUserHandler'] = function() use ( $container) {
167
- return new RegisterUserHandler($container[ 'UserRepository'] );
166
+ $container['RegisterUserHandler'] = function($container) {
167
+ return new RegisterUserHandler($container->get( 'UserRepository');
168
168
};
169
169
```
170
170
@@ -198,24 +198,24 @@ The minimum set up to get the Command Bus working is:
198
198
<?php
199
199
//...your other registered classes
200
200
201
- $container['CommandTranslator'] = function() use ( $container) {
201
+ $container['CommandTranslator'] = function($container) {
202
202
return new \NilPortugues\MessageBus\CommandBus\Translator\AppendStrategy('Handler');
203
203
};
204
204
205
- $container['CommandHandlerResolver'] = function() use ( $container) {
205
+ $container['CommandHandlerResolver'] = function($container) {
206
206
return new \NilPortugues\MessageBus\CommandBus\Resolver\InteropContainerResolver($container);
207
207
};
208
208
209
- $container['CommandBusMiddleware'] = function() use ( $container) {
209
+ $container['CommandBusMiddleware'] = function($container) {
210
210
return new \NilPortugues\MessageBus\CommandBus\CommandBusMiddleware(
211
- $container[ 'CommandTranslator'] ,
212
- $container[ 'CommandHandlerResolver'] ,
211
+ $container->get( 'CommandTranslator') ,
212
+ $container->get( 'CommandHandlerResolver') ,
213
213
);
214
214
};
215
215
216
- $container['CommandBus'] = function() use ( $container) {
216
+ $container['CommandBus'] = function($container) {
217
217
return new \NilPortugues\MessageBus\CommandBus\CommandBus([
218
- $container[ 'CommandBusMiddleware'] ,
218
+ $container->get( 'CommandBusMiddleware') ,
219
219
]);
220
220
};
221
221
```
@@ -226,17 +226,17 @@ If for instance, we want to log everything happening in the Command Bus, we'll a
226
226
<?php
227
227
//...your other registered classes
228
228
229
- $container['LoggerCommandBusMiddleware'] = function() use ( $container) {
229
+ $container['LoggerCommandBusMiddleware'] = function($container) {
230
230
return new \NilPortugues\MessageBus\CommandBus\LoggerCommandBusMiddleware(
231
- $container[ 'Monolog']
231
+ $container->get( 'Monolog')
232
232
);
233
233
};
234
234
235
235
//Update the CommandBus with the LoggerCommandBusMiddleware
236
- $container['CommandBus'] = function() use ( $container) {
236
+ $container['CommandBus'] = function($container) {
237
237
return new \NilPortugues\MessageBus\CommandBus\CommandBus([
238
- $container[ 'LoggerCommandBusMiddleware'] ,
239
- $container[ 'CommandBusMiddleware'] ,
238
+ $container->get( 'LoggerCommandBusMiddleware') ,
239
+ $container->get( 'CommandBusMiddleware') ,
240
240
]);
241
241
};
242
242
```
@@ -360,8 +360,8 @@ For instance, in a `Interop\Container` compliant Service Container, we can do th
360
360
<?php
361
361
//...your other registered classes
362
362
363
- $container['GetUserHandler'] = function() use ( $container) {
364
- return new GetUserHandler($container[ 'UserRepository'] );
363
+ $container['GetUserHandler'] = function($container) {
364
+ return new GetUserHandler($container->get( 'UserRepository') );
365
365
};
366
366
```
367
367
@@ -395,24 +395,24 @@ The minimum set up to get the Query Bus working is:
395
395
<?php
396
396
//...your other registered classes
397
397
398
- $container['QueryTranslator'] = function() use ( $container) {
398
+ $container['QueryTranslator'] = function($container) {
399
399
return new \NilPortugues\MessageBus\QueryBus\Translator\AppendStrategy('Handler');
400
400
};
401
401
402
- $container['QueryHandlerResolver'] = function() use ( $container) {
402
+ $container['QueryHandlerResolver'] = function($container) {
403
403
return new \NilPortugues\MessageBus\QueryBus\Resolver\InteropContainerResolver($container);
404
404
};
405
405
406
- $container['QueryBusMiddleware'] = function() use ( $container) {
406
+ $container['QueryBusMiddleware'] = function($container) {
407
407
return new \NilPortugues\MessageBus\QueryBus\QueryBusMiddleware(
408
- $container[ 'QueryTranslator'] ,
409
- $container[ 'QueryHandlerResolver'] ,
408
+ $container->get( 'QueryTranslator') ,
409
+ $container->get( 'QueryHandlerResolver') ,
410
410
);
411
411
};
412
412
413
- $container['QueryBus'] = function() use ( $container) {
413
+ $container['QueryBus'] = function($container) {
414
414
return new \NilPortugues\MessageBus\QueryBus\QueryBus([
415
- $container[ 'QueryBusMiddleware'] ,
415
+ $container->get( 'QueryBusMiddleware') ,
416
416
]);
417
417
};
418
418
```
@@ -423,17 +423,17 @@ If for instance, we want to log everything happening in the Query Bus, we'll add
423
423
<?php
424
424
//...your other registered classes
425
425
426
- $container['LoggerQueryBusMiddleware'] = function() use ( $container) {
426
+ $container['LoggerQueryBusMiddleware'] = function($container) {
427
427
return new \NilPortugues\MessageBus\QueryBus\LoggerQueryBusMiddleware(
428
- $container[ 'Monolog']
428
+ $container->get( 'Monolog')
429
429
);
430
430
};
431
431
432
432
//Update the QueryBus with the LoggerQueryBusMiddleware
433
- $container['QueryBus'] = function() use ( $container) {
433
+ $container['QueryBus'] = function($container) {
434
434
return new \NilPortugues\MessageBus\QueryBus\QueryBus([
435
- $container[ 'LoggerQueryBusMiddleware'] ,
436
- $container[ 'QueryBusMiddleware'] ,
435
+ $container->get( 'LoggerQueryBusMiddleware') ,
436
+ $container->get( 'QueryBusMiddleware') ,
437
437
]);
438
438
};
439
439
```
@@ -633,26 +633,26 @@ For instance, in a `Interop\Container` compliant Service Container, we can do th
633
633
<?php
634
634
//...your other registered classes
635
635
636
- $container['UserFriendRepository'] = function() use ( $container) {
636
+ $container['UserFriendRepository'] = function($container) {
637
637
return []; //your repository
638
638
};
639
639
640
- $container['UserCreditsRepository'] = function() use ( $container) {
640
+ $container['UserCreditsRepository'] = function($container) {
641
641
return []; //your repository
642
642
};
643
643
644
- $container['EmailProvider'] = function() use ( $container) {
644
+ $container['EmailProvider'] = function($container) {
645
645
return []; //your email provider
646
646
};
647
647
648
- $container['SetupUserAccountHandler'] = function() use ( $container) {
648
+ $container['SetupUserAccountHandler'] = function($container) {
649
649
return new SetupUserAccountHandler(
650
- $container[ 'UserFriendRepository'] ,
651
- $container[ 'UserCreditsRepository']
650
+ $container->get( 'UserFriendRepository') ,
651
+ $container->get( 'UserCreditsRepository')
652
652
);
653
653
};
654
- $container['SendWelcomeEmailHandler'] = function() use ( $container) {
655
- return new SendWelcomeEmailHandler($container[ 'EmailProvider'] );
654
+ $container['SendWelcomeEmailHandler'] = function($container) {
655
+ return new SendWelcomeEmailHandler($container->get( 'EmailProvider');
656
656
};
657
657
```
658
658
@@ -684,7 +684,7 @@ The minimum set up to get the Event Bus working is:
684
684
<?php
685
685
//...your other registered classes
686
686
687
- $container['EventTranslator'] = function() use ( $container) {
687
+ $container['EventTranslator'] = function($container) {
688
688
$handlers = [
689
689
SendWelcomeEmailHandler::class,
690
690
SetupUserAccountHandler::class,
@@ -693,20 +693,20 @@ $container['EventTranslator'] = function() use ($container) {
693
693
return new \NilPortugues\MessageBus\EventBus\Translator\EventFullyQualifiedClassNameStrategy($handlers);
694
694
};
695
695
696
- $container['EventHandlerResolver'] = function() use ( $container) {
696
+ $container['EventHandlerResolver'] = function($container) {
697
697
return new \NilPortugues\MessageBus\EventBus\Resolver\InteropContainerResolver($container);
698
698
};
699
699
700
- $container['EventBusMiddleware'] = function() use ( $container) {
700
+ $container['EventBusMiddleware'] = function($container) {
701
701
return new \NilPortugues\MessageBus\EventBus\EventBusMiddleware(
702
- $container[ 'EventTranslator'] ,
703
- $container[ 'EventHandlerResolver'] ,
702
+ $container->get( 'EventTranslator') ,
703
+ $container->get( 'EventHandlerResolver') ,
704
704
);
705
705
};
706
706
707
- $container['EventBus'] = function() use ( $container) {
707
+ $container['EventBus'] = function($container) {
708
708
return new \NilPortugues\MessageBus\EventBus\EventBus([
709
- $container[ 'EventBusMiddleware'] ,
709
+ $container->get( 'EventBusMiddleware') ,
710
710
]);
711
711
};
712
712
```
@@ -717,17 +717,17 @@ If for instance, we want to log everything happening in the Event Bus, we'll add
717
717
<?php
718
718
//...your other registered classes
719
719
720
- $container['LoggerEventBusMiddleware'] = function() use ( $container) {
720
+ $container['LoggerEventBusMiddleware'] = function($container) {
721
721
return new \NilPortugues\MessageBus\EventBus\LoggerEventBusMiddleware(
722
- $container[ 'Monolog']
722
+ $container->get( 'Monolog')
723
723
);
724
724
};
725
725
726
726
//Update the EventBus with the LoggerEventBusMiddleware
727
- $container['EventBus'] = function() use ( $container) {
727
+ $container['EventBus'] = function($container) {
728
728
return new \NilPortugues\MessageBus\EventBus\EventBus([
729
- $container[ 'LoggerEventBusMiddleware'] ,
730
- $container[ 'EventBusMiddleware'] ,
729
+ $container->get( 'LoggerEventBusMiddleware') ,
730
+ $container->get( 'EventBusMiddleware') ,
731
731
]);
732
732
};
733
733
```
0 commit comments