11<?php
22
3- namespace Drupal \commerce_tax ;
3+ namespace Drupal \commerce ;
44
55use Drupal \Component \Plugin \Exception \PluginException ;
66use Drupal \Component \Plugin \PluginManagerInterface ;
77use Drupal \Core \Plugin \DefaultSingleLazyPluginCollection ;
88
99/**
10- * A collection of tax type plugins .
10+ * A collection that stores a single plugin, aware of its parent entity ID .
1111 */
12- class TaxTypePluginCollection extends DefaultSingleLazyPluginCollection {
12+ class CommerceSinglePluginCollection extends DefaultSingleLazyPluginCollection {
1313
1414 /**
15- * The tax type entity ID this plugin collection belongs to.
15+ * The entity ID this plugin collection belongs to.
1616 *
1717 * @var string
1818 */
1919 protected $ entityId ;
2020
2121 /**
22- * Constructs a new TaxTypePluginCollection object.
22+ * Constructs a new CommerceSinglePluginCollection object.
2323 *
2424 * @param \Drupal\Component\Plugin\PluginManagerInterface $manager
2525 * The manager to be used for instantiating plugins.
@@ -28,20 +28,21 @@ class TaxTypePluginCollection extends DefaultSingleLazyPluginCollection {
2828 * @param array $configuration
2929 * An array of configuration.
3030 * @param string $entity_id
31- * The tax type entity ID this plugin collection belongs to.
31+ * The entity ID this plugin collection belongs to.
3232 */
3333 public function __construct (PluginManagerInterface $ manager , $ instance_id , array $ configuration , $ entity_id ) {
34- parent ::__construct ($ manager , $ instance_id , $ configuration );
35-
3634 $ this ->entityId = $ entity_id ;
35+ // The parent constructor initializes the plugin, so it needs to be called
36+ // after $this->entityId is set.
37+ parent ::__construct ($ manager , $ instance_id , $ configuration );
3738 }
3839
3940 /**
4041 * {@inheritdoc}
4142 */
4243 protected function initializePlugin ($ instance_id ) {
4344 if (!$ instance_id ) {
44- throw new PluginException ("The tax type ' {$ this ->entityId }' did not specify a plugin. " );
45+ throw new PluginException ("The entity ' {$ this ->entityId }' did not specify a plugin. " );
4546 }
4647
4748 $ configuration = ['_entity_id ' => $ this ->entityId ] + $ this ->configuration ;
0 commit comments