- Issue created by @joachim
I was a little over-eager and went to /waste-collection-schedule without having first set up the module.
The page crashes with:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. Valid plugin IDs for Plugin/DataProvider are: csv_data_provider, example_data_provider in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
Drupal\Core\Plugin\DefaultPluginManager->getDefinition() (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance() (Line: 90)
Drupal\localgov_waste_collection\Controller\WasteCollectionController->__construct() (Line: 97)
This is also a situation that could occur if a developer uninstalls the module which provides the plugin which is set. Or if a module update moves the plugin or breaks it.
The controller should recover cleanly from this and show a normal page with an error message -- a badly configured site should never cause an exception.
But it's not really possible to recover from this exception in the controller class's constructor -- we're not in a place where we can return something yet.
I would move these lines:
$plugin_id = $this->config->get('active_data_provider');
$this->dataProvider = $this->dataProviderManager->createInstance($plugin_id);
to a helper method like getDataProvider(), and have the various content callbacks call that when they need the plugin, with a try/catch around it.
Active
1.0
Code