1 | <?php |
||
20 | class WordPoints_Hook_Arg { |
||
21 | |||
22 | /** |
||
23 | * The slug of this arg. |
||
24 | * |
||
25 | * @since 1.0.0 |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $slug; |
||
30 | |||
31 | /** |
||
32 | * The slug of the type of entity that this arg's value is. |
||
33 | * |
||
34 | * @since 1.0.0 |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $entity_slug; |
||
39 | |||
40 | /** |
||
41 | * The action object. |
||
42 | * |
||
43 | * @since 1.0.0 |
||
44 | * |
||
45 | * @var WordPoints_Hook_ActionI |
||
46 | */ |
||
47 | protected $action; |
||
48 | |||
49 | /** |
||
50 | * Whether this arg is stateful or not. |
||
51 | * |
||
52 | * @since 1.0.0 |
||
53 | * |
||
54 | * @var bool |
||
55 | */ |
||
56 | protected $is_stateful = false; |
||
57 | |||
58 | /** |
||
59 | * Construct the arg with a slug. |
||
60 | * |
||
61 | * Slugs are typically the slug of the entity itself, but this isn't always the |
||
62 | * case. Sometimes more than one value associated with an event will be of the |
||
63 | * same type of entity. To work around this, the arg slug can also be an entity |
||
64 | * alias. Entity aliases are just entity slugs that are prefixed with an |
||
65 | * arbitrary string ending in a semicolon. For example, 'current:user' is an |
||
66 | * alias of the User entity. |
||
67 | * |
||
68 | * @since 1.0.0 |
||
69 | * |
||
70 | * @param string $slug The arg slug. |
||
71 | * @param WordPoints_Hook_ActionI $action The calling action's object. |
||
72 | */ |
||
73 | public function __construct( $slug, WordPoints_Hook_ActionI $action = null ) { |
||
86 | |||
87 | /** |
||
88 | * Get the slug of this arg. |
||
89 | * |
||
90 | * @since 1.0.0 |
||
91 | * |
||
92 | * @return string The arg slug. |
||
93 | */ |
||
94 | public function get_slug() { |
||
97 | |||
98 | /** |
||
99 | * Get the slug of the type of entity this arg is. |
||
100 | * |
||
101 | * @since 1.0.0 |
||
102 | * |
||
103 | * @return string The entity slug. |
||
104 | */ |
||
105 | public function get_entity_slug() { |
||
108 | |||
109 | /** |
||
110 | * Get the entity object for this arg's value. |
||
111 | * |
||
112 | * @since 1.0.0 |
||
113 | * |
||
114 | * @return WordPoints_Entity|false The entity, or false if not registered. |
||
115 | */ |
||
116 | public function get_entity() { |
||
128 | |||
129 | /** |
||
130 | * Retrieves the value for this arg. |
||
131 | * |
||
132 | * @since 1.0.0 |
||
133 | * |
||
134 | * @return mixed The arg value. |
||
135 | */ |
||
136 | public function get_value() { |
||
144 | |||
145 | /** |
||
146 | * Retrieves the human-readable title of this arg. |
||
147 | * |
||
148 | * @since 1.0.0 |
||
149 | * |
||
150 | * @return string The arg title. |
||
151 | */ |
||
152 | public function get_title() { |
||
162 | |||
163 | /** |
||
164 | * Check whether the arg is stateful. |
||
165 | * |
||
166 | * @since 1.0.0 |
||
167 | * |
||
168 | * @return bool Whether this arg is stateful. |
||
169 | */ |
||
170 | public function is_stateful() { |
||
173 | } |
||
174 | |||
176 |