Code Duplication    Length = 22-23 lines in 2 locations

code/model/editableformfields/EditableMultipleOptionField.php 1 location

@@ 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

code/model/editableformfields/EditableFormField.php 1 location

@@ 561-583 (lines=23) @@
558
     * @param string $toStage
559
     * @param bool $createNewVersion
560
     */
561
    protected function publishRules($fromStage, $toStage, $createNewVersion)
562
    {
563
        $seenRuleIDs = array();
564
565
        // Don't forget to publish the related custom rules...
566
        foreach ($this->DisplayRules() as $rule) {
567
            $seenRuleIDs[] = $rule->ID;
568
            $rule->doPublish($fromStage, $toStage, $createNewVersion);
569
            $rule->destroy();
570
        }
571
572
        // remove any orphans from the "fromStage"
573
        $rules = Versioned::get_by_stage('EditableCustomRule', $toStage)
574
            ->filter('ParentID', $this->ID);
575
576
        if (!empty($seenRuleIDs)) {
577
            $rules = $rules->exclude('ID', $seenRuleIDs);
578
        }
579
580
        foreach ($rules as $rule) {
581
            $rule->deleteFromStage($toStage);
582
        }
583
    }
584
585
    /**
586
     * Delete this field from a given stage