| @@ 548-570 (lines=23) @@ | ||
| 545 | * @param string $toStage |
|
| 546 | * @param bool $createNewVersion |
|
| 547 | */ |
|
| 548 | protected function publishRules($fromStage, $toStage, $createNewVersion) |
|
| 549 | { |
|
| 550 | $seenRuleIDs = array(); |
|
| 551 | ||
| 552 | // Don't forget to publish the related custom rules... |
|
| 553 | foreach ($this->DisplayRules() as $rule) { |
|
| 554 | $seenRuleIDs[] = $rule->ID; |
|
| 555 | $rule->doPublish($fromStage, $toStage, $createNewVersion); |
|
| 556 | $rule->destroy(); |
|
| 557 | } |
|
| 558 | ||
| 559 | // remove any orphans from the "fromStage" |
|
| 560 | $rules = Versioned::get_by_stage('EditableCustomRule', $toStage) |
|
| 561 | ->filter('ParentID', $this->ID); |
|
| 562 | ||
| 563 | if (!empty($seenRuleIDs)) { |
|
| 564 | $rules = $rules->exclude('ID', $seenRuleIDs); |
|
| 565 | } |
|
| 566 | ||
| 567 | foreach ($rules as $rule) { |
|
| 568 | $rule->deleteFromStage($toStage); |
|
| 569 | } |
|
| 570 | } |
|
| 571 | ||
| 572 | /** |
|
| 573 | * Delete this field from a given stage |
|
| @@ 110-131 (lines=22) @@ | ||
| 107 | * @param string $toStage |
|
| 108 | * @param bool $createNewVersion |
|
| 109 | */ |
|
| 110 | protected function publishOptions($fromStage, $toStage, $createNewVersion) |
|
| 111 | { |
|
| 112 | $seenIDs = array(); |
|
| 113 | ||
| 114 | // Publish all options |
|
| 115 | foreach ($this->Options() as $option) { |
|
| 116 | $seenIDs[] = $option->ID; |
|
| 117 | $option->publish($fromStage, $toStage, $createNewVersion); |
|
| 118 | } |
|
| 119 | ||
| 120 | // remove any orphans from the "fromStage" |
|
| 121 | $options = Versioned::get_by_stage('EditableOption', $toStage) |
|
| 122 | ->filter('ParentID', $this->ID); |
|
| 123 | ||
| 124 | if (!empty($seenIDs)) { |
|
| 125 | $options = $options->exclude('ID', $seenIDs); |
|
| 126 | } |
|
| 127 | ||
| 128 | foreach ($options as $rule) { |
|
| 129 | $rule->deleteFromStage($toStage); |
|
| 130 | } |
|
| 131 | } |
|
| 132 | ||
| 133 | /** |
|
| 134 | * Unpublishing Versioning support |
|