diff --git a/core/lib/Drupal/Core/Plugin/DefaultSinglePluginBag.php b/core/lib/Drupal/Core/Plugin/DefaultSinglePluginBag.php index 13428ae..a9618c0 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultSinglePluginBag.php +++ b/core/lib/Drupal/Core/Plugin/DefaultSinglePluginBag.php @@ -12,6 +12,12 @@ /** * Provides a default plugin bag for a plugin type. + * + * A plugin bag usually stores multiple plugins, and is used to lazily + * instantiate them. When only one plugin is needed, it is still best practice + * to encapsulate all of the instantiation logic in a plugin bag. This class can + * be used directly, or subclassed to add further exception handling in + * self::initializePlugin(). */ class DefaultSinglePluginBag extends PluginBag { @@ -23,6 +29,8 @@ class DefaultSinglePluginBag extends PluginBag { protected $manager; /** + * An array of configuration to instantiate the plugin with. + * * @var array */ protected $configuration; diff --git a/core/modules/block/lib/Drupal/block/BlockPluginBag.php b/core/modules/block/lib/Drupal/block/BlockPluginBag.php index e71fcca..6a2fd12 100644 --- a/core/modules/block/lib/Drupal/block/BlockPluginBag.php +++ b/core/modules/block/lib/Drupal/block/BlockPluginBag.php @@ -9,6 +9,7 @@ use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\PluginManagerInterface; +use Drupal\Component\Utility\String; use Drupal\Core\Plugin\DefaultSinglePluginBag; /** @@ -37,7 +38,7 @@ public function __construct(PluginManagerInterface $manager, array $instance_ids */ protected function initializePlugin($instance_id) { if (!$instance_id) { - throw new PluginException(format_string("The block '@block' did not specify a plugin.", array('@block' => $this->blockId))); + throw new PluginException(String::format("The block '@block' did not specify a plugin.", array('@block' => $this->blockId))); } try {