Elgg  Version 1.11
EventsService.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg;
4 
15 
16  const OPTION_STOPPABLE = 'stoppable';
17  const OPTION_DEPRECATION_MESSAGE = 'deprecation_message';
18  const OPTION_DEPRECATION_VERSION = 'deprecation_version';
19 
27  public function trigger($event, $type, $object = null, array $options = array()) {
28  $options = array_merge(array(
29  self::OPTION_STOPPABLE => true,
30  self::OPTION_DEPRECATION_MESSAGE => '',
31  self::OPTION_DEPRECATION_VERSION => '',
32  ), $options);
33 
34  $events = $this->hasHandler($event, $type);
35  if ($events && $options[self::OPTION_DEPRECATION_MESSAGE]) {
37  $options[self::OPTION_DEPRECATION_MESSAGE],
38  $options[self::OPTION_DEPRECATION_VERSION],
39  2
40  );
41  }
42 
43  $events = $this->getOrderedHandlers($event, $type);
44  $args = array($event, $type, $object);
45 
46  foreach ($events as $callback) {
47  if (!is_callable($callback)) {
48  if ($this->logger) {
49  $inspector = new Inspector();
50  $this->logger->warn("handler for event [$event, $type] is not callable: "
51  . $inspector->describeCallable($callback));
52  }
53  continue;
54  }
55 
56  $return = call_user_func_array($callback, $args);
57  if (!empty($options[self::OPTION_STOPPABLE]) && ($return === false)) {
58  return false;
59  }
60  }
61 
62  return true;
63  }
64 }
trigger($event, $type, $object=null, array $options=array())
Triggers an Elgg event.
$object
Definition: upgrade.php:12
$return
Definition: opendd.php:15
$args
Some servers don&#39;t allow PHP to check the rewrite, so try via AJAX.
$options
Definition: index.php:14
Save menu items.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1006
$type
Definition: add.php:8