diff --git a/src/FacetSource/FacetSourcePluginManager.php b/src/FacetSource/FacetSourcePluginManager.php index 4f4146a..960f86a 100644 --- a/src/FacetSource/FacetSourcePluginManager.php +++ b/src/FacetSource/FacetSourcePluginManager.php @@ -2,6 +2,7 @@ namespace Drupal\facets\FacetSource; +use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; @@ -22,4 +23,17 @@ class FacetSourcePluginManager extends DefaultPluginManager { parent::__construct('Plugin/facets/facet_source', $namespaces, $module_handler, 'Drupal\facets\FacetSource\FacetSourcePluginInterface', 'Drupal\facets\Annotation\FacetsFacetSource'); } + /** + * {@inheritdoc} + */ + public function processDefinition(&$definition, $plugin_id) { + parent::processDefinition($definition, $plugin_id); + + foreach (['id', 'label', 'description','display_id'] as $required_property) { + if (empty($definition[$required_property])) { + throw new PluginException(sprintf('The facet source plugin %s must define the %s property.', $plugin_id, $required_property)); + } + } + } + }