-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitk_pretix.api.php
More file actions
44 lines (37 loc) · 1.26 KB
/
itk_pretix.api.php
File metadata and controls
44 lines (37 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* @file
* Hooks provided by the ITK Pretix module.
*/
use Drupal\itk_pretix\Pretix\EventHelper;
use Drupal\node\NodeInterface;
/**
* Perform alterations on liveness of the pretix event shop.
*/
function hook_itk_pretix_shop_live_alter(&$live, NodeInterface $node) {
if ($node->field_cancelled->value) {
$live = FALSE;
}
}
/**
* Perform alterations on pretix event api data.
*
* @see https://docs.pretix.eu/en/latest/api/resources/events.html
*/
function hookitk_pretix_event_data_alter(array &$data, NodeInterface $node, array $context) {
$isNewevent = $context['is_new_event'] ?? FALSE;
$data['presale_end'] = (new Date())->format(EventHelper::DATETIME_FORMAT);
}
/**
* Perform alterations on pretix sub-event api data.
*
* @see https://docs.pretix.eu/en/latest/api/resources/subevents.html
*/
function hook_itk_pretix_subevent_data_alter(array &$data, NodeInterface $node, array $context) {
$isNewSubevent = $context['is_new_subevent'] ?? FALSE;
/** @var ?\ItkDev\Pretix\Api\Entity\Event $event */
$event = $context['event'] ?? NULL;
/** @var ?\Drupal\itk_pretix\Plugin\Field\FieldType\PretixDate $pretixDate */
$pretixDate = $context['pretix_date'] ?? NULL;
$data['presale_end'] = (new Date())->format(EventHelper::DATETIME_FORMAT);
}