Commit 4951407e authored by nicola85's avatar nicola85

Add hook alters

parent 5839b262
<?php
/**
* @file
* This file contains no working PHP code; it exists to provide additional
* documentation for doxygen as well as to document hooks in the standard
* Drupal manner.
*/
/**
* Alter units index calendar.
*
* @param array $units
*/
function hook_bat_api_units_index_calendar_alter(&$units) {
// No example.
}
/**
* Alter events index calendar.
*
* @param array $events
* @param array $context
*/
function hook_bat_api_events_index_calendar_alter(&$events, $context) {
// No example.
}
/**
* Alter matching units calendar.
*
* @param array $events
* @param array $context
*/
function hook_bat_api_matching_units_calendar_alter(&$events, $context) {
// No example.
}
......@@ -184,7 +184,18 @@ class CalendarEventsIndex extends ServiceDefinitionBase implements ContainerFact
}
}
return $events_json;
$context = array(
'unit_ids' => $unit_ids,
'unit_types' => $unit_types,
'start_date' => $start_date_object,
'end_date' => $end_date_object,
'event_types' => $event_types,
'background' => $background,
);
\Drupal::moduleHandler()->alter('bat_api_events_index_calendar', $events_json, $context);
return array_values($events_json);
}
public function getReferencedIds($unit_type, $ids = []) {
......
......@@ -181,6 +181,16 @@ class MatchingUnitIndex extends ServiceDefinitionBase implements ContainerFactor
$events_json = bat_api_merge_non_blocking_events($events_json);
$context = array(
'unit_types' => $unit_types,
'start_date' => $start_date_object,
'end_date' => $end_date_object,
'event_type' => $event_type,
'event_states' => $event_states,
);
\Drupal::moduleHandler()->alter('bat_api_matching_units_calendar', $events_json, $context);
return array_values($events_json);
}
......
......@@ -146,6 +146,8 @@ class UnitIndex extends ServiceDefinitionBase implements ContainerFactoryPluginI
}
}
\Drupal::moduleHandler()->alter('bat_api_units_index_calendar', $units);
return $units;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment