diff options
author | Marcin Czołnowski <marcin@czolnowski.net> | 2014-09-11 13:33:01 +0400 |
---|---|---|
committer | Marcin Czołnowski <marcin@czolnowski.net> | 2014-09-11 13:33:01 +0400 |
commit | f93850a6508a720c8381d15af72393d78a6a8237 (patch) | |
tree | 9972f354466ecef524df0434949a1c36102efc59 /core/Plugin/Segment.php | |
parent | 52230fb700f0bea2b59f655ba7c4559aa079d0f5 (diff) |
Add setter for suggested values callback.
Use suggested values callback in getSuggestedValuesForSegment API method.
Diffstat (limited to 'core/Plugin/Segment.php')
-rw-r--r-- | core/Plugin/Segment.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/Plugin/Segment.php b/core/Plugin/Segment.php index 4281495a35..cc3392eebc 100644 --- a/core/Plugin/Segment.php +++ b/core/Plugin/Segment.php @@ -50,6 +50,7 @@ class Segment private $sqlFilterValue; private $acceptValues; private $permission; + private $suggestedValuesCallback; /** * @ignore @@ -186,6 +187,15 @@ class Segment } /** + * Set callback which will be executed when user will call for suggested values for segment. + * + * @param callable $suggestedValuesCallback + */ + public function setSuggestedValuesCallback($suggestedValuesCallback) { + $this->suggestedValuesCallback = $suggestedValuesCallback; + } + + /** * You can restrict the access to this segment by passing a boolean `false`. For instance if you want to make * a certain segment only available to users having super user access you could do the following: * `$segment->setPermission(Piwik::hasUserSuperUserAccess());` @@ -227,6 +237,10 @@ class Segment $segment['permission'] = $this->permission; } + if (is_callable($this->suggestedValuesCallback)) { + $segment['suggestedValuesCallback'] = $this->suggestedValuesCallback; + } + return $segment; } } |