-
Notifications
You must be signed in to change notification settings - Fork 0
/
_generic.php
107 lines (71 loc) · 1.99 KB
/
_generic.php
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
#
# A MediaWiki bot - used for automated tasks on sites powered by MediaWiki.
# Line: Worker: Set signal param class
#
# Author: Grigor Gatchev <grigor at gatchev dot info>
# Licensed under GNU Affero Public License, version 3.0 or any later.
#
# ---------------------------------------------------------------------------- #
require_once ( dirname ( __FILE__ ) . '/../_generic.php' );
abstract class Worker_SetParam extends Worker_Params
{
# ----- Overriding ----- #
protected function signal_log_slot_name ()
{
return parent::signal_log_slot_name() . ".Set";
}
protected function get_params ()
{
$params = parent::get_params();
$this->_get_param ( $params, 'name' );
$this->_get_param ( $params, 'group' );
return $params;
}
protected function set_params ( $params )
{
$this->_set_param ( $params, 'name' );
$this->_set_param ( $params, 'group' );
return parent::set_params ( $params );
}
# ----- Implemented ----- #
protected function new_param ( &$signal )
{
$value = $this->new_paramvalue ( $signal );
if ( is_null ( $value ) )
return NULL;
return $signal->set_param ( $this->group, $this->name, $value );
}
# ----- New (Checks for mandatory worker properties) ----- #
protected function die_on_unset_property ( $name )
{
if ( ! isset ( $this->$name ) )
{
$this->log ( '$' . $name . ' property is not set - cannot work!',
LL_PANIC );
die();
}
}
protected function die_on_nonnumeric_property ( $name )
{
$this->die_on_unset_property ( $name );
if ( ! is_numeric ( $this->$name ) )
{
$this->log ( '$' . $name . ' property is not numeric - cannot work!',
LL_PANIC );
die();
}
}
protected function die_on_nonstring_property ( $name )
{
$this->die_on_unset_property ( $name );
if ( ! is_string ( $this->$name ) )
{
$this->log ( '$' . $name . ' property is not string - cannot work!',
LL_PANIC );
die();
}
}
# ----- Abstract ----- #
abstract protected function new_paramvalue ( &$signal );
}