Projet

Général

Profil

Révision 950416da

Ajouté par Assos Assos il y a plus de 5 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/rules/includes/rules.event.inc
70 70
   * Returns an array of default settings.
71 71
   *
72 72
   * @return array
73
   *   The array of default settings.
73 74
   */
74 75
  public function getDefaults();
75 76

  
......
145 146
   *   The info array of the event the event handler belongs to.
146 147
   */
147 148
  public function getEventInfo();
149

  
148 150
}
149 151

  
150 152
/**
......
169 171
   *   TRUE if the event dispatcher is currently active, FALSE otherwise.
170 172
   */
171 173
  public function isWatching();
174

  
172 175
}
173 176

  
174 177
/**
......
198 201
  protected $settings = array();
199 202

  
200 203
  /**
201
   * Implements RulesEventHandlerInterface::__construct()
204
   * Implements RulesEventHandlerInterface::__construct().
202 205
   */
203 206
  public function __construct($event_name, $info) {
204 207
    $this->eventName = $event_name;
......
207 210
  }
208 211

  
209 212
  /**
210
   * Implements RulesEventHandlerInterface::getSettings()
213
   * Implements RulesEventHandlerInterface::getSettings().
211 214
   */
212 215
  public function getSettings() {
213 216
    return $this->settings;
214 217
  }
215 218

  
216 219
  /**
217
   * Implements RulesEventHandlerInterface::setSettings()
220
   * Implements RulesEventHandlerInterface::setSettings().
218 221
   */
219 222
  public function setSettings(array $settings) {
220 223
    $this->settings = $settings + $this->getDefaults();
......
222 225
  }
223 226

  
224 227
  /**
225
   * Implements RulesEventHandlerInterface::validate()
228
   * Implements RulesEventHandlerInterface::validate().
226 229
   */
227 230
  public function validate() {
228 231
    // Nothing to check by default.
229 232
  }
230 233

  
231 234
  /**
232
   * Implements RulesEventHandlerInterface::extractFormValues()
235
   * Implements RulesEventHandlerInterface::extractFormValues().
233 236
   */
234 237
  public function extractFormValues(array &$form, array &$form_state) {
235 238
    foreach ($this->getDefaults() as $key => $setting) {
......
238 241
  }
239 242

  
240 243
  /**
241
   * Implements RulesEventHandlerInterface::availableVariables()
244
   * Implements RulesEventHandlerInterface::availableVariables().
242 245
   */
243 246
  public function availableVariables() {
244 247
    return isset($this->eventInfo['variables']) ? $this->eventInfo['variables'] : array();
245 248
  }
246 249

  
247 250
  /**
248
   * Implements RulesEventHandlerInterface::getEventName()
251
   * Implements RulesEventHandlerInterface::getEventName().
249 252
   */
250 253
  public function getEventName() {
251 254
    return $this->eventName;
252 255
  }
253 256

  
254 257
  /**
255
   * Implements RulesEventHandlerInterface::getEventInfo()
258
   * Implements RulesEventHandlerInterface::getEventInfo().
256 259
   */
257 260
  public function getEventInfo() {
258 261
    return $this->eventInfo;
259 262
  }
263

  
260 264
}
261 265

  
262 266
/**
263 267
 * A handler for events having no settings. This is the default handler.
264 268
 */
265
class RulesEventDefaultHandler extends RulesEventHandlerBase  {
269
class RulesEventDefaultHandler extends RulesEventHandlerBase {
266 270

  
267 271
  /**
268
   * Implements RulesEventHandlerInterface::buildForm()
272
   * Implements RulesEventHandlerInterface::buildForm().
269 273
   */
270 274
  public function buildForm(array &$form_state) {
271 275
    return array();
272 276
  }
273 277

  
274 278
  /**
275
   * Implements RulesEventHandlerInterface::getConfiguredEventName()
279
   * Implements RulesEventHandlerInterface::getConfiguredEventName().
276 280
   */
277 281
  public function getEventNameSuffix() {
278 282
    return '';
279 283
  }
280 284

  
281 285
  /**
282
   * Implements RulesEventHandlerInterface::summary()
286
   * Implements RulesEventHandlerInterface::summary().
283 287
   */
284 288
  public function summary() {
285 289
    return check_plain($this->eventInfo['label']);
286 290
  }
287 291

  
288 292
  /**
289
   * Implements RulesEventHandlerInterface::getDefaults()
293
   * Implements RulesEventHandlerInterface::getDefaults().
290 294
   */
291 295
  public function getDefaults() {
292 296
    return array();
293 297
  }
294 298

  
295 299
  /**
296
   * Implements RulesEventHandlerInterface::getSettings()
300
   * Implements RulesEventHandlerInterface::getSettings().
297 301
   */
298 302
  public function getSettings() {
299 303
    return NULL;
300 304
  }
305

  
301 306
}
302 307

  
303 308
/**
......
305 310
 */
306 311
class RulesEventHandlerEntityBundle extends RulesEventHandlerBase {
307 312

  
308
  protected $entityType, $entityInfo, $bundleKey;
313
  protected $entityType;
314
  protected $entityInfo;
315
  protected $bundleKey;
309 316

  
310 317
  /**
311
   * Implements RulesEventHandlerInterface::__construct()
318
   * Implements RulesEventHandlerInterface::__construct().
312 319
   */
313 320
  public function __construct($event_name, $info) {
314 321
    parent::__construct($event_name, $info);
......
321 328
  }
322 329

  
323 330
  /**
324
   * Implements RulesEventHandlerInterface::summary()
331
   * Implements RulesEventHandlerInterface::summary().
325 332
   */
326 333
  public function summary() {
327 334
    $bundle = &$this->settings['bundle'];
......
331 338
  }
332 339

  
333 340
  /**
334
   * Implements RulesEventHandlerInterface::buildForm()
341
   * Implements RulesEventHandlerInterface::buildForm().
335 342
   */
336 343
  public function buildForm(array &$form_state) {
337 344
    $form['bundle'] = array(
......
340 347
      '#description' => t('If you need to filter for multiple values, either add multiple events or use the "Entity is of bundle" condition instead.'),
341 348
      '#default_value' => $this->settings['bundle'],
342 349
      '#empty_value' => '',
350
      '#options' => array(),
343 351
    );
344 352
    foreach ($this->entityInfo['bundles'] as $name => $bundle_info) {
345 353
      $form['bundle']['#options'][$name] = $bundle_info['label'];
......
351 359
   * Returns the label to use for the bundle property.
352 360
   *
353 361
   * @return string
362
   *   The label to use for the bundle property.
354 363
   */
355 364
  protected function getBundlePropertyLabel() {
356 365
    return $this->entityInfo['entity keys']['bundle'];
357 366
  }
358 367

  
359 368
  /**
360
   * Implements RulesEventHandlerInterface::extractFormValues()
369
   * Implements RulesEventHandlerInterface::extractFormValues().
361 370
   */
362 371
  public function extractFormValues(array &$form, array &$form_state) {
363 372
    $this->settings['bundle'] = !empty($form_state['values']['bundle']) ? $form_state['values']['bundle'] : NULL;
364 373
  }
365 374

  
366 375
  /**
367
   * Implements RulesEventHandlerInterface::validate()
376
   * Implements RulesEventHandlerInterface::validate().
368 377
   */
369 378
  public function validate() {
370 379
    if ($this->settings['bundle'] && empty($this->entityInfo['bundles'][$this->settings['bundle']])) {
......
373 382
          '%bundle' => $this->settings['bundle'],
374 383
          '%entity_type' => $this->entityInfo['label'],
375 384
          '@bundle' => $this->getBundlePropertyLabel(),
376
      )), array(NULL, 'bundle'));
385
        )), array(NULL, 'bundle'));
377 386
    }
378 387
  }
379 388

  
380 389
  /**
381
   * Implements RulesEventHandlerInterface::getConfiguredEventName()
390
   * Implements RulesEventHandlerInterface::getConfiguredEventName().
382 391
   */
383 392
  public function getEventNameSuffix() {
384 393
    return $this->settings['bundle'];
385 394
  }
386 395

  
387 396
  /**
388
   * Implements RulesEventHandlerInterface::getDefaults()
397
   * Implements RulesEventHandlerInterface::getDefaults().
389 398
   */
390 399
  public function getDefaults() {
391 400
    return array(
......
394 403
  }
395 404

  
396 405
  /**
397
   * Implements RulesEventHandlerInterface::availableVariables()
406
   * Implements RulesEventHandlerInterface::availableVariables().
398 407
   */
399 408
  public function availableVariables() {
400 409
    $variables = $this->eventInfo['variables'];
......
408 417
    }
409 418
    return $variables;
410 419
  }
420

  
411 421
}

Formats disponibles : Unified diff