Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit a2e6614

Browse files
committed
Added documentation on updating plugin managers
If a plugin manager defined invokable classes previously via properties, it will need to update these entries.
1 parent 86b3438 commit a2e6614

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

doc/book/migration.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,46 @@ version 2 in version 3. However, we recommend starting to update your
9595
configuration to remove `invokables` entries in favor of factories (and aliases,
9696
if needed).
9797

98+
> #### Invokables and plugin managers
99+
>
100+
> If you are creating a plugin manager and in-lining invokables into the class
101+
> definition, you will need to make some changes.
102+
>
103+
> `$invokableClasses` will need to become `$factories` entries, and you will
104+
> potentially need to add `$aliases` entries.
105+
>
106+
> As an example, consider the following, from zend-math v2.x:
107+
>
108+
> ```php
109+
> class AdapterPluginManager extends AbstractPluginManager
110+
> {
111+
> protected $invokableClasses = [
112+
> 'bcmath' => Adapter\Bcmath::class,
113+
> 'gmp' => Adapter\Gmp::class,
114+
> ];
115+
> }
116+
> ```
117+
>
118+
> Because we no longer define an `$invokableClasses` property, for v3.x, this
119+
> now becomes:
120+
>
121+
> ```php
122+
> use Zend\ServiceManager\Factory\InvokableFactory;
123+
>
124+
> class AdapterPluginManager extends AbstractPluginManager
125+
> {
126+
> protected $aliases = [
127+
> 'bcmath' => Adapter\Bcmath::class,
128+
> 'gmp' => Adapter\Gmp::class,
129+
> ];
130+
>
131+
> protected $factories = [
132+
> Adapter\BcMath::class => InvokableFactory::class,
133+
> Adapter\Gmp::class => InvokableFactory::class,
134+
> ];
135+
> }
136+
> ```
137+
98138
### Lazy Services
99139
100140
In v2, if you wanted to create a lazy service, you needed to take the following

0 commit comments

Comments
 (0)