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.plugins.inc
1 1
<?php
2 2

  
3 3
/**
4
 * @file Contains plugin info and implementations not needed for rule evaluation.
4
 * @file
5
 * Contains plugin info and implementations not needed for rule evaluation.
5 6
 */
6 7

  
7

  
8 8
/**
9 9
 * Implements a rules action.
10 10
 */
11 11
class RulesAction extends RulesAbstractPlugin implements RulesActionInterface {
12 12

  
13
  /**
14
   * @var string
15
   */
13 16
  protected $itemName = 'action';
14 17

  
15 18
  /**
......
69 72
      }
70 73
    }
71 74
  }
75

  
72 76
}
73 77

  
74 78
/**
......
76 80
 */
77 81
class RulesCondition extends RulesAbstractPlugin implements RulesConditionInterface {
78 82

  
83
  /**
84
   * @var string
85
   */
79 86
  protected $itemName = 'condition';
87

  
88
  /**
89
   * @var bool
90
   */
80 91
  protected $negate = FALSE;
81 92

  
82 93
  public function providesVariables() {
......
132 143

  
133 144
  public function label() {
134 145
    $label = parent::label();
135
    return $this->negate ? t('NOT @condition', array('@condition' => $label)) : $label;
146
    return $this->negate ? t('NOT !condition', array('!condition' => $label)) : $label;
136 147
  }
148

  
137 149
}
138 150

  
139 151
/**
140 152
 * An actual rule.
153
 *
141 154
 * Note: A rule also implements the RulesActionInterface (inherited).
142 155
 */
143 156
class Rule extends RulesActionContainer {
144 157

  
145 158
  protected $conditions = NULL;
159

  
160
  /**
161
   * @var string
162
   */
146 163
  protected $itemName = 'rule';
147 164

  
165
  /**
166
   * @var string
167
   */
148 168
  public $label = 'unlabeled';
149 169

  
150 170
  public function __construct($variables = array(), $providesVars = array()) {
......
159 179
  }
160 180

  
161 181
  /**
162
   * Get an iterator over all contained conditions. Note that this iterator also
163
   * implements the ArrayAcces interface.
182
   * Gets an iterator over all contained conditions.
183
   *
184
   * Note that this iterator also implements the ArrayAccess interface.
164 185
   *
165 186
   * @return RulesRecursiveElementIterator
166 187
   */
......
183 204
  }
184 205

  
185 206
  /**
186
   * Get an iterator over all contained actions. Note that this iterator also
187
   * implements the ArrayAccess interface.
207
   * Gets an iterator over all contained actions.
208
   *
209
   * Note that this iterator also implements the ArrayAccess interface.
188 210
   *
189 211
   * @return RulesRecursiveElementIterator
190 212
   */
......
193 215
  }
194 216

  
195 217
  /**
196
   * Add a condition. Pass either an instance of the RulesConditionInterface
197
   * or the arguments as needed by rules_condition().
218
   * Adds a condition.
198 219
   *
199
   * @return Rule
200
   *   Returns $this to support chained usage.
220
   * Pass either an instance of the RulesConditionInterface or the arguments as
221
   * needed by rules_condition().
222
   *
223
   * @return $this
201 224
   */
202 225
  public function condition($name, $settings = array()) {
203 226
    $this->conditions->condition($name, $settings);
......
309 332
  }
310 333

  
311 334
  /**
312
   * Rules may not provided any variable info assertions, as Rules are only
335
   * Overrides RulesPlugin::variableInfoAssertions().
336
   *
337
   * Rules may not provide any variable info assertions, as Rules are only
313 338
   * conditionally executed.
314 339
   */
315 340
  protected function variableInfoAssertions() {
......
324 349
  }
325 350

  
326 351
  /**
327
   * Overriden to expose the variables of all actions for embedded rules.
352
   * Overridden to expose the variables of all actions for embedded rules.
328 353
   */
329 354
  public function providesVariables() {
330 355
    $provides = parent::providesVariables();
......
340 365
    parent::resetInternalCache();
341 366
    $this->conditions->resetInternalCache();
342 367
  }
368

  
343 369
}
344 370

  
345 371
/**
......
347 373
 */
348 374
class RulesReactionRule extends Rule implements RulesTriggerableInterface {
349 375

  
376
  /**
377
   * @var string
378
   */
350 379
  protected $itemName = 'reaction rule';
351
  protected $events = array(), $eventSettings = array();
380

  
381
  /**
382
   * @var array
383
   */
384
  protected $events = array();
385

  
386
  /**
387
   * @var array
388
   */
389
  protected $eventSettings = array();
352 390

  
353 391
  /**
354 392
   * Implements RulesTriggerableInterface::events().
......
516 554
    // No need to keep event settings for evaluation.
517 555
    $this->eventSettings = array();
518 556
  }
557

  
519 558
}
520 559

  
521 560
/**
......
523 562
 */
524 563
class RulesAnd extends RulesConditionContainer {
525 564

  
565
  /**
566
   * @var string
567
   */
526 568
  protected $itemName = 'and';
527 569

  
528 570
  public function evaluate(RulesState $state) {
......
539 581
  public function label() {
540 582
    return !empty($this->label) ? $this->label : ($this->negate ? t('NOT AND') : t('AND'));
541 583
  }
584

  
542 585
}
543 586

  
544 587
/**
......
546 589
 */
547 590
class RulesOr extends RulesConditionContainer {
548 591

  
592
  /**
593
   * @var string
594
   */
549 595
  protected $itemName = 'or';
550 596

  
551 597
  public function evaluate(RulesState $state) {
......
564 610
  }
565 611

  
566 612
  /**
613
   * Overrides RulesContainerPlugin::stateVariables().
614
   *
567 615
   * Overridden to exclude all variable assertions as in an OR we cannot assert
568 616
   * the children are successfully evaluated.
569 617
   */
......
580 628
    }
581 629
    return $vars;
582 630
  }
631

  
583 632
}
584 633

  
585 634
/**
......
587 636
 */
588 637
class RulesLoop extends RulesActionContainer {
589 638

  
639
  /**
640
   * @var string
641
   */
590 642
  protected $itemName = 'loop';
591 643
  protected $listItemInfo;
592 644

  
......
693 745
      $this->settings['item:label'] = reset($export['ITEM']);
694 746
    }
695 747
  }
748

  
696 749
}
697 750

  
698 751
/**
......
700 753
 */
701 754
class RulesActionSet extends RulesActionContainer {
702 755

  
756
  /**
757
   * @var string
758
   */
703 759
  protected $itemName = 'action set';
704 760

  
705 761
}
......
709 765
 */
710 766
class RulesRuleSet extends RulesActionContainer {
711 767

  
768
  /**
769
   * @var string
770
   */
712 771
  protected $itemName = 'rule set';
713 772

  
714 773
  /**
......
725 784
  protected function importChildren($export, $key = 'RULES') {
726 785
    parent::importChildren($export, $key);
727 786
  }
787

  
728 788
}
729 789

  
730 790
/**
......
732 792
 */
733 793
class RulesEventSet extends RulesRuleSet {
734 794

  
795
  /**
796
   * @var string
797
   */
735 798
  protected $itemName = 'event set';
736
  // Event sets may recurse as we block recursions on rule-level.
799

  
800
  /**
801
   * Event sets may recurse as we block recursions on rule-level.
802
   *
803
   * @var bool
804
   */
737 805
  public $recursion = TRUE;
738 806

  
739 807
  public function __construct($info = array()) {
......
751 819
  }
752 820

  
753 821
  /**
754
   * Cache event-sets per event to allow efficient usage via rules_invoke_event().
822
   * Rebuilds the event cache.
823
   *
824
   * We cache event-sets per event in order to allow efficient usage via
825
   * rules_invoke_event().
755 826
   *
756 827
   * @see rules_get_cache()
757 828
   * @see rules_invoke_event()
......
824 895
  public function save($name = NULL, $module = 'rules') {
825 896
    return FALSE;
826 897
  }
898

  
827 899
}

Formats disponibles : Unified diff