PluginHelper.php 983 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Drupal\Component\Plugin;
  3. /**
  4. * A helper class to determine if a plugin is configurable.
  5. *
  6. * Because configurable plugins in Drupal 8 might implement either the
  7. * deprecated ConfigurablePluginInterface or the new ConfigurableInterface,
  8. * this static method is provided so that a calling class can determine if a
  9. * plugin is configurable without checking it against a deprecated interface.
  10. * In Drupal 9, this check should be reduced to checking for
  11. * ConfigurableInterface only and be deprecated in favor of calling classes
  12. * checking against the interface directly.
  13. */
  14. class PluginHelper {
  15. /**
  16. * Determines if a plugin is configurable.
  17. *
  18. * @param mixed $plugin
  19. * The plugin to check.
  20. *
  21. * @return bool
  22. * A boolean indicating whether the plugin is configurable.
  23. */
  24. public static function isConfigurable($plugin) {
  25. return $plugin instanceof ConfigurableInterface || $plugin instanceof ConfigurablePluginInterface;
  26. }
  27. }