PluginHooksService.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Elgg;
  3. use Elgg\Debug\Inspector;
  4. /**
  5. * WARNING: API IN FLUX. DO NOT USE DIRECTLY.
  6. *
  7. * Use the elgg_* versions instead.
  8. *
  9. * @access private
  10. *
  11. * @package Elgg.Core
  12. * @subpackage Hooks
  13. * @since 1.9.0
  14. */
  15. class PluginHooksService extends \Elgg\HooksRegistrationService {
  16. /**
  17. * Triggers a plugin hook
  18. *
  19. * @see elgg_trigger_plugin_hook
  20. * @access private
  21. */
  22. public function trigger($hook, $type, $params = null, $returnvalue = null) {
  23. $hooks = $this->getOrderedHandlers($hook, $type);
  24. foreach ($hooks as $callback) {
  25. if (!is_callable($callback)) {
  26. if ($this->logger) {
  27. $inspector = new Inspector();
  28. $this->logger->warn("handler for plugin hook [$hook, $type] is not callable: "
  29. . $inspector->describeCallable($callback));
  30. }
  31. continue;
  32. }
  33. $args = array($hook, $type, $returnvalue, $params);
  34. $temp_return_value = call_user_func_array($callback, $args);
  35. if (!is_null($temp_return_value)) {
  36. $returnvalue = $temp_return_value;
  37. }
  38. }
  39. return $returnvalue;
  40. }
  41. }