* The event inspector is a development tool which provides metadata about events.
* It can be used for code-generators and documentation-generators.
*
- * @code
+ * ```
* $i = new CiviEventInspector();
* print_r(CRM_Utils_Array::collect('name', $i->getAll()));
- * @endCode
+ * ```
*
* An event definition includes these fields:
* - type: string, required. Ex: 'hook' or 'object'
* @see \CRM_Utils_Hook::eventDefs()
*/
public static function findBuiltInEvents(\Civi\Core\Event\GenericHookEvent $e) {
- $skipList = array('singleton');
+ $skipList = ['singleton'];
$e->inspector->addStaticStubs('CRM_Utils_Hook', 'hook_civicrm_',
function ($eventDef, $method) use ($skipList) {
return in_array($method->name, $skipList) ? NULL : $eventDef;
*/
public function build($force = FALSE) {
if ($force || $this->eventDefs === NULL) {
- $this->eventDefs = array();
+ $this->eventDefs = [];
\CRM_Utils_Hook::eventDefs($this);
ksort($this->eventDefs);
}
return FALSE;
}
- if (!in_array($eventDef['type'], array('hook', 'object'))) {
+ if (!in_array($eventDef['type'], ['hook', 'object'])) {
return FALSE;
}
* @return CiviEventInspector
*/
public function add($eventDef) {
- $name = isset($eventDef['name']) ? $eventDef['name'] : NULL;
+ $name = $eventDef['name'] ?? NULL;
if (!isset($eventDef['type'])) {
$eventDef['type'] = preg_match('/^hook_/', $eventDef['name']) ? 'hook' : 'object';
* @return CiviEventInspector
*/
public function addEventClass($event, $className) {
- $this->add(array(
+ $this->add([
'name' => $event,
'class' => $className,
- ));
+ ]);
return $this;
}
continue;
}
- $eventDef = array(
+ $eventDef = [
'name' => $prefix . $method->name,
'description_html' => $method->getDocComment() ? \CRM_Admin_Page_APIExplorer::formatDocBlock($method->getDocComment()) : '',
- 'fields' => array(),
+ 'fields' => [],
'class' => 'Civi\Core\Event\GenericHookEvent',
'stub' => $method,
- );
+ ];
foreach ($method->getParameters() as $parameter) {
- $eventDef['fields'][$parameter->getName()] = array(
+ $eventDef['fields'][$parameter->getName()] = [
'name' => $parameter->getName(),
'ref' => (bool) $parameter->isPassedByReference(),
// WISHLIST: 'type' => 'mixed',
- );
+ ];
}
if ($filter !== NULL) {