From 6d01411ea02f93048ac7d09a29d3a03c7a382015 Mon Sep 17 00:00:00 2001
From: mattab <matthieu.aubry@gmail.com>
Date: Mon, 17 Feb 2014 17:57:38 +1300
Subject: [PATCH] Refactor this code to limit duplication.

---
 plugins/SegmentEditor/SegmentEditor.php | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/plugins/SegmentEditor/SegmentEditor.php b/plugins/SegmentEditor/SegmentEditor.php
index 2441e4d559..544c5d69d6 100644
--- a/plugins/SegmentEditor/SegmentEditor.php
+++ b/plugins/SegmentEditor/SegmentEditor.php
@@ -59,12 +59,7 @@ class SegmentEditor extends \Piwik\Plugin
             return;
         }
 
-        $model = new Model();
-        $segmentsToAutoArchive = $model->getSegmentsToAutoArchive($idSite = false);
-
-        foreach ($segmentsToAutoArchive as $segment) {
-            $segments[] = $segment['definition'];
-        }
+        $this->getKnownSegmentsToArchiveForSite($segments, $idSite = false);
     }
 
     public function getKnownSegmentsToArchiveForSite(&$segments, $idSite)
@@ -75,11 +70,9 @@ class SegmentEditor extends \Piwik\Plugin
 
         $model = new Model();
         $segmentToAutoArchive = $model->getSegmentsToAutoArchive($idSite);
-
         foreach ($segmentToAutoArchive as $segmentInfo) {
             $segments[] = $segmentInfo['definition'];
         }
-
         $segments = array_unique($segments);
     }
 
-- 
GitLab