-
Notifications
You must be signed in to change notification settings - Fork 0
/
spectrum.module
50 lines (42 loc) · 1.23 KB
/
spectrum.module
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
45
46
47
48
49
50
<?php
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\spectrum\Query\Query;
use Drupal\spectrum\Triggers\ModelTrigger;
function spectrum_entity_presave($entity)
{
ModelTrigger::handle($entity, 'presave');
}
function spectrum_entity_insert($entity)
{
ModelTrigger::handle($entity, 'insert');
}
function spectrum_entity_update($entity)
{
ModelTrigger::handle($entity, 'update');
}
function spectrum_entity_predelete($entity)
{
ModelTrigger::handle($entity, 'predelete');
}
function spectrum_entity_delete($entity)
{
ModelTrigger::handle($entity, 'delete');
}
// We need the Alter query hook to parse expressions that were added to the Spectrum Query
function spectrum_query_spectrum_query_alter(AlterableInterface $drupalQuery)
{
/** @var Query $query */
$query = $drupalQuery->getMetaData('spectrum_query');
$query->parseExpressions($drupalQuery);
}
/**
* Implements hook_query_tag_alter().
*
* @param \Drupal\Core\Database\Query\AlterableInterface $drupalQuery
*/
function spectrum_query_spectrum_query_use_access_policy_alter(AlterableInterface $drupalQuery)
{
/** @var \Drupal\spectrum\Query\ModelQuery $query */
$query = $drupalQuery->getMetaData('spectrum_query');
$query->executeAccessPolicy($drupalQuery);
}