-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSaveTypes.module
68 lines (50 loc) · 1.4 KB
/
SaveTypes.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php namespace ProcessWire;
/**
* Save Room Module
*
* Adds hooks to handle all the necessary steps that are needed to
* save the Room template
*
* @attention: Please look into SaveSensor.module for more detailed comments.
*/
class SaveTypes extends WireData implements Module {
/**
* getModuleInfo required by module interface
* @return array
*/
public static function getModuleInfo() {
return array(
'title' => 'Save actions for Types template',
'version' => "0.1.1",
'summary' => 'Simple module to manage save actions on template Types.',
'singular' => true,
'autoload' => true,
//'icon' => 'smile-o',
);
}
/**
* Initialize the module
*/
public function init() {
// add a hook after the $pages->save, to issue hook every time a page is saved
$this->pages->addHookAfter('saveReady', $this, 'calculateType');
}
/**
* Hook for saving template Room
*
* @param HookEvent $event
*/
public function calculateType($event) {
$page = $event->arguments(0);
$settings= wire('pages')->get('/settings/');
// return if not relevant
if($page->template->name !== 'Type') return;
// ////////////////////
// set default values
// ////////////////////
// Do Checks
// ////////////////////
// calculate fields
//@TODO Add a check to avoid turning off types that have active Sensors
}
}