Elgg  Version 1.10
EventsService.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg;
3 
14 
15  const OPTION_STOPPABLE = 'stoppable';
16  const OPTION_DEPRECATION_MESSAGE = 'deprecation_message';
17  const OPTION_DEPRECATION_VERSION = 'deprecation_version';
18 
26  public function trigger($event, $type, $object = null, array $options = array()) {
27  $options = array_merge(array(
28  self::OPTION_STOPPABLE => true,
29  self::OPTION_DEPRECATION_MESSAGE => '',
30  self::OPTION_DEPRECATION_VERSION => '',
31  ), $options);
32 
33  $events = $this->hasHandler($event, $type);
34  if ($events && $options[self::OPTION_DEPRECATION_MESSAGE]) {
36  $options[self::OPTION_DEPRECATION_MESSAGE],
37  $options[self::OPTION_DEPRECATION_VERSION],
38  2
39  );
40  }
41 
42  $events = $this->getOrderedHandlers($event, $type);
43  $args = array($event, $type, $object);
44 
45  foreach ($events as $callback) {
46  if (!is_callable($callback)) {
47  if ($this->logger) {
48  $this->logger->warn("handler for event [$event, $type] is not callable: "
49  . $this->describeCallable($callback));
50  }
51  continue;
52  }
53 
54  $return = call_user_func_array($callback, $args);
55  if (!empty($options[self::OPTION_STOPPABLE]) && ($return === false)) {
56  return false;
57  }
58  }
59 
60  return true;
61  }
62 }
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)
Sends a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1055
$type
Definition: add.php:8