diff options
author | diosmosis <benaka@piwik.pro> | 2015-08-06 14:54:34 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-08-07 17:15:43 +0300 |
commit | 2f91d3c83a834b0e451d3e58fa246ef0a87740fb (patch) | |
tree | 4c650ff22651921af10f84344557bf78106f4952 /plugins/CoreHome | |
parent | 0f67ba1ae63db2ccef642ef215002379c3ee8bfe (diff) |
Add public methods to VisitProperties for property access and use instead of direct access.
Diffstat (limited to 'plugins/CoreHome')
-rw-r--r-- | plugins/CoreHome/Tracker/VisitRequestProcessor.php | 16 | ||||
-rw-r--r-- | plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/plugins/CoreHome/Tracker/VisitRequestProcessor.php b/plugins/CoreHome/Tracker/VisitRequestProcessor.php index ee7493c68d..7d963303ce 100644 --- a/plugins/CoreHome/Tracker/VisitRequestProcessor.php +++ b/plugins/CoreHome/Tracker/VisitRequestProcessor.php @@ -83,16 +83,16 @@ class VisitRequestProcessor extends RequestProcessor public function processRequestParams(VisitProperties $visitProperties, Request $request) { // the IP is needed by isExcluded() and GoalManager->recordGoals() - $visitProperties->visitorInfo['location_ip'] = $request->getIp(); + $visitProperties->setProperty('location_ip', $request->getIp()); // TODO: move VisitExcluded logic to here (or move to service class stored in DI) - $excluded = new VisitExcluded($request, $visitProperties->visitorInfo['location_ip']); + $excluded = new VisitExcluded($request, $visitProperties->getProperty('location_ip')); if ($excluded->isExcluded()) { return true; } // visitor recognition - $visitorId = $this->userSettings->getConfigId($request, $visitProperties->visitorInfo['location_ip']); + $visitorId = $this->userSettings->getConfigId($request, $visitProperties->getProperty('location_ip')); $visitProperties->setRequestMetadata('CoreHome', 'visitorId', $visitorId); $isKnown = $this->visitorRecognizer->findKnownVisitor($visitorId, $visitProperties, $request); @@ -106,6 +106,8 @@ class VisitRequestProcessor extends RequestProcessor public function afterRequestProcessed(VisitProperties $visitProperties, Request $request) { + $ip = $visitProperties->getProperty('location_ip'); + /** * Triggered after visits are tested for exclusion so plugins can modify the IP address * persisted with a visit. @@ -114,7 +116,9 @@ class VisitRequestProcessor extends RequestProcessor * * @param string &$ip The visitor's IP address. */ - $this->eventDispatcher->postEvent('Tracker.setVisitorIp', array(&$visitProperties->visitorInfo['location_ip'])); + $this->eventDispatcher->postEvent('Tracker.setVisitorIp', array(&$ip)); + + $visitProperties->setProperty('location_ip', $ip); } /** @@ -157,7 +161,7 @@ class VisitRequestProcessor extends RequestProcessor */ protected function isLastActionInTheSameVisit(VisitProperties $visitProperties, Request $request) { - $lastActionTime = $visitProperties->visitorInfo['visit_last_action_time']; + $lastActionTime = $visitProperties->getProperty('visit_last_action_time'); return isset($lastActionTime) && false !== $lastActionTime @@ -171,7 +175,7 @@ class VisitRequestProcessor extends RequestProcessor */ private function wasLastActionNotToday(VisitProperties $visitProperties, Request $request) { - $lastActionTime = $visitProperties->visitorInfo['visit_last_action_time']; + $lastActionTime = $visitProperties->getProperty('visit_last_action_time'); if (empty($lastActionTime)) { return false; diff --git a/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php b/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php index fc9e9ad423..b4507eb74c 100644 --- a/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php +++ b/plugins/CoreHome/tests/Integration/Tracker/VisitRequestProcessorTest.php @@ -99,7 +99,7 @@ class VisitRequestProcessorTest extends IntegrationTestCase list($visit, $request) = $this->prepareVisitWithRequest(array('idsite' => $idsite), $currentActionTime); $visitProperties = new VisitProperties(); - $visitProperties->visitorInfo = array('visit_last_action_time' => Date::factory($lastActionTimestamp)->getTimestamp()); + $visitProperties->setProperty('visit_last_action_time', Date::factory($lastActionTimestamp)->getTimestamp()); $visitProperties->setRequestMetadata('CoreHome', 'isVisitorKnown', $isVisitorKnown); return array($visit, $visitProperties, $request); |