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

@@ 545-567 (lines=23) @@
542
     * @param string $toStage
543
     * @param bool $createNewVersion
544
     */
545
    protected function publishRules($fromStage, $toStage, $createNewVersion)
546
    {
547
        $seenRuleIDs = array();
548
549
        // Don't forget to publish the related custom rules...
550
        foreach ($this->DisplayRules() as $rule) {
551
            $seenRuleIDs[] = $rule->ID;
552
            $rule->doPublish($fromStage, $toStage, $createNewVersion);
553
            $rule->destroy();
554
        }
555
556
        // remove any orphans from the "fromStage"
557
        $rules = Versioned::get_by_stage('EditableCustomRule', $toStage)
558
            ->filter('ParentID', $this->ID);
559
560
        if (!empty($seenRuleIDs)) {
561
            $rules = $rules->exclude('ID', $seenRuleIDs);
562
        }
563
564
        foreach ($rules as $rule) {
565
            $rule->deleteFromStage($toStage);
566
        }
567
    }
568
569
    /**
570
     * Delete this field from a given stage