diff options
author | diosmosis <benaka@piwik.pro> | 2015-07-10 06:44:05 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-08-06 17:37:59 +0300 |
commit | df6a92196d292510a0744c4eae3ff861a3136899 (patch) | |
tree | 09a2007553dced98f447c0dd4be1b6f7225fe2f5 | |
parent | 31b93051749f8e7a2f4f8a7ac0fc52124af525f5 (diff) |
Change RequestProcessor method names and remove need to supply Request to Visitor object.
-rw-r--r-- | core/Tracker/GoalManager.php | 20 | ||||
-rw-r--r-- | core/Tracker/RequestProcessor.php | 6 | ||||
-rw-r--r-- | core/Tracker/Visit.php | 6 | ||||
-rw-r--r-- | core/Tracker/Visitor.php | 9 | ||||
-rw-r--r-- | plugins/Actions/Tracker/ActionsRequestProcessor.php | 6 | ||||
-rw-r--r-- | plugins/CoreHome/Tracker/VisitRequestProcessor.php | 6 | ||||
-rw-r--r-- | plugins/Goals/Tracker/GoalsRequestProcessor.php | 7 | ||||
-rw-r--r-- | plugins/Heartbeat/Tracker/PingRequestProcessor.php | 2 |
8 files changed, 28 insertions, 34 deletions
diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php index c7cde6a622..ce1532d860 100644 --- a/core/Tracker/GoalManager.php +++ b/core/Tracker/GoalManager.php @@ -237,7 +237,7 @@ class GoalManager * @param array $visitCustomVariables * @param Action $action */ - public function recordGoals(VisitProperties $visitProperties, Request $request) + public function recordGoals(VisitProperties $visitProperties) { $visitorInformation = $visitProperties->visitorInfo; $visitCustomVariables = $visitProperties->getRequestMetadata('CustomVariables', 'visitCustomVariables'); @@ -245,7 +245,7 @@ class GoalManager /** @var Action $action */ $action = $visitProperties->getRequestMetadata('Actions', 'action'); - $goal = $this->getGoalFromVisitor($visitProperties, $request, $action); + $goal = $this->getGoalFromVisitor($visitProperties, $action); // Copy Custom Variables from Visit row to the Goal conversion // Otherwise, set the Custom Variables found in the cookie sent with this request @@ -267,9 +267,9 @@ class GoalManager // some goals are converted, so must be ecommerce Order or Cart Update if ($this->requestIsEcommerce) { - $this->recordEcommerceGoal($visitProperties, $request, $goal, $action); + $this->recordEcommerceGoal($visitProperties, $goal, $action); } else { - $this->recordStandardGoals($visitProperties, $request, $goal, $action); + $this->recordStandardGoals($visitProperties, $goal, $action); } } @@ -299,13 +299,13 @@ class GoalManager * @param Action $action * @param array $visitInformation */ - protected function recordEcommerceGoal(VisitProperties $visitProperties, Request $request, $conversion, $action) + protected function recordEcommerceGoal(VisitProperties $visitProperties, $conversion, $action) { if ($this->isThereExistingCartInVisit) { Common::printDebug("There is an existing cart for this visit"); } - $visitor = Visitor::makeFromVisitProperties($visitProperties, $request); + $visitor = Visitor::makeFromVisitProperties($visitProperties); if ($this->isGoalAnOrder) { $debugMessage = 'The conversion is an Ecommerce order'; @@ -674,9 +674,9 @@ class GoalManager * @param Action $action * @param $visitorInformation */ - protected function recordStandardGoals(VisitProperties $visitProperties, Request $request, $goal, $action) + protected function recordStandardGoals(VisitProperties $visitProperties, $goal, $action) { - $visitor = Visitor::makeFromVisitProperties($visitProperties, $request); + $visitor = Visitor::makeFromVisitProperties($visitProperties); foreach ($this->convertedGoals as $convertedGoal) { $this->currentGoal = $convertedGoal; @@ -816,7 +816,7 @@ class GoalManager return $valuesToUpdate; } - private function getGoalFromVisitor(VisitProperties $visitProperties, Request $request, $action) + private function getGoalFromVisitor(VisitProperties $visitProperties, $action) { $goal = array( 'idvisit' => $visitProperties->visitorInfo['idvisit'], @@ -826,7 +826,7 @@ class GoalManager $visitDimensions = VisitDimension::getAllDimensions(); - $visit = Visitor::makeFromVisitProperties($visitProperties, $request); + $visit = Visitor::makeFromVisitProperties($visitProperties); foreach ($visitDimensions as $dimension) { $value = $dimension->onAnyGoalConversion($this->request, $visit, $action); if (false !== $value) { diff --git a/core/Tracker/RequestProcessor.php b/core/Tracker/RequestProcessor.php index f25b43f0d4..f6cdb02538 100644 --- a/core/Tracker/RequestProcessor.php +++ b/core/Tracker/RequestProcessor.php @@ -12,8 +12,6 @@ use Piwik\Tracker\Visit\VisitProperties; /** * TODO - * - * TODO: maybe we should rename manipulateVisitProperties to afterRequestProcessed and rename processRequest to handleRequest or recordLogs */ abstract class RequestProcessor { @@ -28,7 +26,7 @@ abstract class RequestProcessor /** * TODO */ - public function manipulateVisitProperties(VisitProperties $visitProperties, Request $request) + public function afterRequestProcessed(VisitProperties $visitProperties, Request $request) { return false; } @@ -52,7 +50,7 @@ abstract class RequestProcessor /** * TODO */ - public function processRequest(VisitProperties $visitProperties, Request $request) + public function recordLogs(VisitProperties $visitProperties ) { // empty } diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index 2a6ac0cbf8..151838fd80 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -125,7 +125,7 @@ class Visit implements VisitInterface } foreach ($this->requestProcessors as $processor) { - $abort = $processor->manipulateVisitProperties($this->visitProperties, $this->request); + $abort = $processor->afterRequestProcessed($this->visitProperties, $this->request); if ($abort) { return; } @@ -160,7 +160,7 @@ class Visit implements VisitInterface $this->request->setThirdPartyCookie($this->visitProperties->visitorInfo['idvisitor']); foreach ($this->requestProcessors as $processor) { - $processor->processRequest($this->visitProperties, $this->request); + $processor->recordLogs($this->visitProperties, $this->request); } $this->markArchivedReportsAsInvalidIfArchiveAlreadyFinished(); @@ -568,6 +568,6 @@ class Visit implements VisitInterface private function makeVisitorFacade() { - return Visitor::makeFromVisitProperties($this->visitProperties, $this->request); + return Visitor::makeFromVisitProperties($this->visitProperties); } } diff --git a/core/Tracker/Visitor.php b/core/Tracker/Visitor.php index efa88a8d96..c8ec1802bd 100644 --- a/core/Tracker/Visitor.php +++ b/core/Tracker/Visitor.php @@ -9,7 +9,6 @@ namespace Piwik\Tracker; use Piwik\Config; -use Piwik\Container\StaticContainer; use Piwik\Plugin\Dimension\VisitDimension; use Piwik\Tracker; use Piwik\Tracker\Visit\VisitProperties; @@ -17,20 +16,18 @@ use Piwik\Tracker\Visit\VisitProperties; class Visitor { private $visitorKnown = false; - private $request; private $visitProperties; - public function __construct(Request $request, VisitProperties $visitProperties, $isVisitorKnown = false) + public function __construct(VisitProperties $visitProperties, $isVisitorKnown = false) { - $this->request = $request; $this->visitProperties = $visitProperties; $this->setIsVisitorKnown($isVisitorKnown); } - public static function makeFromVisitProperties(VisitProperties $visitProperties, Request $request) + public static function makeFromVisitProperties(VisitProperties $visitProperties) { $isKnown = $visitProperties->getRequestMetadata('CoreHome', 'isVisitorKnown'); - return new Visitor($request, $visitProperties, $isKnown); + return new Visitor($visitProperties, $isKnown); } public function setVisitorColumn($column, $value) // TODO: remove this eventually diff --git a/plugins/Actions/Tracker/ActionsRequestProcessor.php b/plugins/Actions/Tracker/ActionsRequestProcessor.php index 225f09499a..1a0dcb4809 100644 --- a/plugins/Actions/Tracker/ActionsRequestProcessor.php +++ b/plugins/Actions/Tracker/ActionsRequestProcessor.php @@ -30,7 +30,7 @@ class ActionsRequestProcessor extends RequestProcessor $visitProperties->setRequestMetadata('Actions', 'action', $action); } - public function manipulateVisitProperties(VisitProperties $visitProperties, Request $request) + public function afterRequestProcessed(VisitProperties $visitProperties, Request $request) { /** @var Action $action */ $action = $visitProperties->getRequestMetadata('Actions', 'action'); @@ -45,7 +45,7 @@ class ActionsRequestProcessor extends RequestProcessor $visitProperties->setRequestMetadata('Actions', 'idReferrerActionName', @$visitProperties->visitorInfo['visit_exit_idaction_name']); } - public function processRequest(VisitProperties $visitProperties, Request $request) + public function recordLogs(VisitProperties $visitProperties) { /** @var Action $action */ $action = $visitProperties->getRequestMetadata('Actions', 'action'); @@ -61,7 +61,7 @@ class ActionsRequestProcessor extends RequestProcessor $idReferrerActionName = $visitProperties->getRequestMetadata('Actions', 'idReferrerActionName'); } - $visitor = Visitor::makeFromVisitProperties($visitProperties, $request); + $visitor = Visitor::makeFromVisitProperties($visitProperties); $action->record($visitor, $idReferrerActionUrl, $idReferrerActionName); } } diff --git a/plugins/CoreHome/Tracker/VisitRequestProcessor.php b/plugins/CoreHome/Tracker/VisitRequestProcessor.php index f33c899118..e57bc219f8 100644 --- a/plugins/CoreHome/Tracker/VisitRequestProcessor.php +++ b/plugins/CoreHome/Tracker/VisitRequestProcessor.php @@ -61,7 +61,7 @@ class VisitRequestProcessor extends RequestProcessor // the IP is needed by isExcluded() and GoalManager->recordGoals() $visitProperties->visitorInfo['location_ip'] = $request->getIp(); - // TODO: move VisitExcluded logic to here (or break into other request processors) + // TODO: move VisitExcluded logic to here (or move to service class stored in DI) $excluded = new VisitExcluded($request, $visitProperties->visitorInfo['location_ip']); if ($excluded->isExcluded()) { return true; @@ -80,7 +80,7 @@ class VisitRequestProcessor extends RequestProcessor return false; } - public function manipulateVisitProperties(VisitProperties $visitProperties, Request $request) + public function afterRequestProcessed(VisitProperties $visitProperties) { /** * Triggered after visits are tested for exclusion so plugins can modify the IP address @@ -135,7 +135,7 @@ class VisitRequestProcessor extends RequestProcessor return isset($lastActionTime) && false !== $lastActionTime - && ($lastActionTime > ($request->getCurrentTimestamp() - $this->visitStandardLength)); // TODO: move to DI + && ($lastActionTime > ($request->getCurrentTimestamp() - $this->visitStandardLength)); } /** diff --git a/plugins/Goals/Tracker/GoalsRequestProcessor.php b/plugins/Goals/Tracker/GoalsRequestProcessor.php index 5336f4fbb9..686649f629 100644 --- a/plugins/Goals/Tracker/GoalsRequestProcessor.php +++ b/plugins/Goals/Tracker/GoalsRequestProcessor.php @@ -14,7 +14,6 @@ use Piwik\Tracker\GoalManager; use Piwik\Tracker\Request; use Piwik\Tracker\RequestProcessor; use Piwik\Tracker\Visit\VisitProperties; -use Piwik\Tracker\Visitor; /** * TODO @@ -53,7 +52,7 @@ class GoalsRequestProcessor extends RequestProcessor return false; } - public function manipulateVisitProperties(VisitProperties $visitProperties, Request $request) + public function afterRequestProcessed(VisitProperties $visitProperties, Request $request) { $visitsConverted = $visitProperties->getRequestMetadata('Goals', 'visitIsConverted'); // TODO: double check, should this be visitIsConverted or someGoalsConverted? @@ -77,7 +76,7 @@ class GoalsRequestProcessor extends RequestProcessor } } - public function processRequest(VisitProperties $visitProperties, Request $request) + public function recordLogs(VisitProperties $visitProperties) { $isManualGoalConversion = self::$goalManager->isManualGoalConversion(); $requestIsEcommerce = self::$goalManager->requestIsEcommerce; @@ -100,7 +99,7 @@ class GoalsRequestProcessor extends RequestProcessor // record the goals if there were conversions in this request (even if the visit itself was not converted) if ($visitProperties->getRequestMetadata('Goals', 'someGoalsConverted')) { - self::$goalManager->recordGoals($visitProperties, $request); + self::$goalManager->recordGoals($visitProperties); } } } diff --git a/plugins/Heartbeat/Tracker/PingRequestProcessor.php b/plugins/Heartbeat/Tracker/PingRequestProcessor.php index 9e45e0c057..3e4decabf4 100644 --- a/plugins/Heartbeat/Tracker/PingRequestProcessor.php +++ b/plugins/Heartbeat/Tracker/PingRequestProcessor.php @@ -27,7 +27,7 @@ class PingRequestProcessor extends RequestProcessor } } - public function manipulateVisitProperties(VisitProperties $visitProperties, Request $request) + public function afterRequestProcessed(VisitProperties $visitProperties, Request $request) { if ($this->isPingRequest($request)) { $visitProperties->setRequestMetadata('Goals', 'someGoalsConverted', false); |