diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-11-19 07:12:24 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-11-19 07:14:32 +0300 |
commit | ada836d750a74ddfda03b48baf2fa1c1173e39ff (patch) | |
tree | c479878e9b79d8883e03d8c302463e4a9a791297 /core/Plugin/Segment.php | |
parent | 0bbf8eb60be3e205d7c230e430ebd7765ef38526 (diff) |
make new operators available in the UI, moved check to segment data class
Diffstat (limited to 'core/Plugin/Segment.php')
-rw-r--r-- | core/Plugin/Segment.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/Plugin/Segment.php b/core/Plugin/Segment.php index 3d6914fe5c..2a20208ea2 100644 --- a/core/Plugin/Segment.php +++ b/core/Plugin/Segment.php @@ -7,6 +7,7 @@ * */ namespace Piwik\Plugin; +use Exception; /** * Creates a new segment that can be used for instance within the {@link \Piwik\Columns\Dimension::configureSegment()} @@ -123,6 +124,7 @@ class Segment public function setSegment($segment) { $this->segment = $segment; + $this->check(); } /** @@ -166,6 +168,7 @@ class Segment public function setSqlSegment($sqlSegment) { $this->sqlSegment = $sqlSegment; + $this->check(); } /** @@ -178,6 +181,7 @@ class Segment public function setUnionOfSegments($segments) { $this->unionOfSegments = $segments; + $this->check(); } /** @@ -323,4 +327,15 @@ class Segment { $this->requiresAtLeastViewAccess = $requiresAtLeastViewAccess; } + + private function check() + { + if ($this->sqlSegment && $this->unionOfSegments) { + throw new Exception(sprintf('Union of segments and SQL segment is set for segment "%s", use only one of them', $this->name)); + } + + if ($this->segment && $this->unionOfSegments && in_array($this->segment, $this->unionOfSegments, true)) { + throw new Exception(sprintf('The segment %s contains a union segment to itself', $this->name)); + } + } } |