@@ -32,6 +32,30 @@ All notable changes to this project will be documented in this file, in reverse
32
32
- [ #230 ] ( https://github.com/zendframework/zend-servicemanager/pull/230 ) fixes a
33
33
problem in detecting cyclic aliases, ensuring they are detected correctly.
34
34
35
+ ## 3.4.0 - TBD
36
+
37
+ ### Added
38
+
39
+ - [ #275 ] ( https://github.com/zendframework/zend-servicemanager/pull/275 ) Enables
40
+ plugin managers to accept as a creation context PSR Containers not implementing
41
+ Interop interface
42
+
43
+ ### Changed
44
+
45
+ - Nothing.
46
+
47
+ ### Deprecated
48
+
49
+ - Nothing.
50
+
51
+ ### Removed
52
+
53
+ - Nothing.
54
+
55
+ ### Fixed
56
+
57
+ - Nothing.
58
+
35
59
## 3.3.2 - 2018-01-29
36
60
37
61
### Added
@@ -91,7 +115,7 @@ All notable changes to this project will be documented in this file, in reverse
91
115
container-interop at a minimum version of 1.2.0, and adding a requirement on
92
116
psr/container 1.0. ` Zend\ServiceManager\ServiceLocatorInterface ` now
93
117
explicitly extends the ` ContainerInterface ` from both projects.
94
-
118
+
95
119
Factory interfaces still typehint against the container-interop variant, as
96
120
changing the typehint would break backwards compatibility. Users can
97
121
duck-type most of these interfaces, however, by creating callables or
@@ -369,7 +393,7 @@ Documentation is now available at http://zend-servicemanager.rtfd.org
369
393
(previously, it was the third).
370
394
371
395
Example:
372
-
396
+
373
397
``` php
374
398
$sm = new \Zend\ServiceManager\ServiceManager([
375
399
'factories' => [
@@ -378,7 +402,7 @@ Documentation is now available at http://zend-servicemanager.rtfd.org
378
402
'MyClassC' => 'MyFactory' // This is equivalent as using ::class
379
403
],
380
404
]);
381
-
405
+
382
406
$sm->get(MyClassA::class); // MyFactory will receive MyClassA::class as second parameter
383
407
```
384
408
@@ -397,7 +421,7 @@ Documentation is now available at http://zend-servicemanager.rtfd.org
397
421
if ($instance instanceof \Zend\Validator\ValidatorInterface) {
398
422
return;
399
423
}
400
-
424
+
401
425
throw new InvalidServiceException(sprintf(
402
426
'Plugin manager "%s" expected an instance of type "%s", but "%s" was received',
403
427
__CLASS__,
@@ -407,19 +431,19 @@ Documentation is now available at http://zend-servicemanager.rtfd.org
407
431
}
408
432
}
409
433
```
410
-
434
+
411
435
In version 3, this becomes:
412
-
436
+
413
437
``` php
414
438
use Zend\ServiceManager\AbstractPluginManager;
415
439
use Zend\Validator\ValidatorInterface;
416
-
440
+
417
441
class MyPluginManager extends AbstractPluginManager
418
442
{
419
443
protected $instanceOf = ValidatorInterface::class;
420
444
}
421
445
```
422
-
446
+
423
447
Of course, you can still override the ` validate ` method if your logic is more
424
448
complex.
425
449
@@ -463,17 +487,17 @@ changes, outlined in this section.
463
487
service manager; you can pass the configuration array directly instead.
464
488
465
489
In version 2.x:
466
-
490
+
467
491
``` php
468
492
$config = new \Zend\ServiceManager\Config([
469
493
'factories' => [...]
470
494
]);
471
-
495
+
472
496
$sm = new \Zend\ServiceManager\ServiceManager($config);
473
497
```
474
-
498
+
475
499
In ZF 3.x:
476
-
500
+
477
501
``` php
478
502
$sm = new \Zend\ServiceManager\ServiceManager([
479
503
'factories' => [...]
@@ -502,7 +526,7 @@ changes, outlined in this section.
502
526
argument if present.
503
527
504
528
For instance, here is a simple version 2.x factory:
505
-
529
+
506
530
``` php
507
531
class MyFactory implements FactoryInterface
508
532
{
@@ -512,9 +536,9 @@ changes, outlined in this section.
512
536
}
513
537
}
514
538
```
515
-
539
+
516
540
The equivalent version 3 factory:
517
-
541
+
518
542
``` php
519
543
class MyFactory implements FactoryInterface
520
544
{
@@ -544,23 +568,23 @@ changes, outlined in this section.
544
568
through the interface.
545
569
546
570
In version 2.x, if a factory was set to a service name defined in a plugin manager:
547
-
571
+
548
572
``` php
549
573
class MyFactory implements FactoryInterface
550
574
{
551
575
function createService(ServiceLocatorInterface $sl)
552
576
{
553
577
// $sl is actually a plugin manager
554
-
578
+
555
579
$parentLocator = $sl->getServiceLocator();
556
-
580
+
557
581
// ...
558
582
}
559
583
}
560
584
```
561
-
585
+
562
586
In version 3:
563
-
587
+
564
588
``` php
565
589
class MyFactory implements FactoryInterface
566
590
{
0 commit comments