@@ -1158,7 +1158,7 @@ To prepare this for version 3, we need to do the following:
1158
1158
` factories ` and ` aliases ` .
1159
1159
- We need to implement a ` validate() ` method.
1160
1160
- We need to update the ` validatePlugin() ` method to proxy to ` validate() ` .
1161
- - We need to add a ` $sharedByDefault ` property (if ` $shareByDefault ` is present)
1161
+ - We need to add a ` $sharedByDefault ` property (if ` $shareByDefault ` is present).
1162
1162
1163
1163
Doing so, we get the following result:
1164
1164
@@ -1227,17 +1227,19 @@ Things to note about the above:
1227
1227
being generated, and these are mapped to ` InvokableFactory ` instances. This
1228
1228
means you can also fetch your plugins by their FQCN.
1229
1229
- There are also factory entries for the canonicalized FQCN of each factory,
1230
- which will be used in v2.
1230
+ which will be used in v2. (Canonicalization in v2 strips non-alphanumeric
1231
+ characters, and casts to lowercase.)
1231
1232
- ` validatePlugin() ` continues to throw the old exception
1232
1233
1233
1234
The above will now work in both version 2 and version 3.
1234
1235
1235
1236
### Migration testing
1236
1237
1237
- To test your changes, create a new ` MigrationTest ` case that uses the
1238
- ` CommonPluginManagerTrait ` . Override the ` getPluginManager() ` to return an
1239
- instance of your plugin manager and override ` getV2InvalidPluginException() `
1240
- to return the classname of the exception your ` validatePlugin() ` method throws:
1238
+ To test your changes, create a new ` MigrationTest ` case that uses
1239
+ ` Zend\ServiceManager\Test\CommonPluginManagerTrait ` . Override
1240
+ ` getPluginManager() ` to return an instance of your plugin manager, and override
1241
+ ` getV2InvalidPluginException() ` to return the classname of the exception your
1242
+ ` validatePlugin() ` method throws:
1241
1243
1242
1244
``` php
1243
1245
use MyNamespace\ObserverInterface;
@@ -1270,10 +1272,10 @@ class MigrationTest extends TestCase
1270
1272
1271
1273
This will check that:
1272
1274
1273
- - You have set the ` $instanceOf ` property
1274
- - ` $shareByDefault ` and ` $sharedByDefault ` match, if present
1275
- - That requesting an invalid plugin throws the right exception
1276
- - That all your aliases resolve
1275
+ - You have set the ` $instanceOf ` property.
1276
+ - ` $shareByDefault ` and ` $sharedByDefault ` match, if present.
1277
+ - That requesting an invalid plugin throws the right exception.
1278
+ - That all your aliases resolve.
1277
1279
1278
1280
1279
1281
### Post migration
0 commit comments