Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-12-04 05:04:02 +0300
committerThomas Steur <thomas.steur@googlemail.com>2014-12-04 05:04:02 +0300
commit9d71fc8e92e5b434fd69c7ab4b83a69169064cf3 (patch)
tree8cb2798746e4defb1a978cd758df72006ec419ae /core/Tracker/Visit
parent784b738f9c4a92c42a9d8e6b85c28a82a3af0a2f (diff)
Tracker refactoring
Diffstat (limited to 'core/Tracker/Visit')
-rw-r--r--core/Tracker/Visit/Factory.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/core/Tracker/Visit/Factory.php b/core/Tracker/Visit/Factory.php
new file mode 100644
index 0000000000..71362dddea
--- /dev/null
+++ b/core/Tracker/Visit/Factory.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+
+namespace Piwik\Tracker\Visit;
+use Piwik\Piwik;
+use Piwik\Tracker\Visit;
+use Piwik\Tracker\VisitInterface;
+use Exception;
+
+class Factory
+{
+ /**
+ * Returns the Tracker_Visit object.
+ * This method can be overwritten to use a different Tracker_Visit object
+ *
+ * @throws Exception
+ * @return \Piwik\Tracker\Visit
+ */
+ public static function make()
+ {
+ $visit = null;
+
+ /**
+ * Triggered before a new **visit tracking object** is created. Subscribers to this
+ * event can force the use of a custom visit tracking object that extends from
+ * {@link Piwik\Tracker\VisitInterface}.
+ *
+ * @param \Piwik\Tracker\VisitInterface &$visit Initialized to null, but can be set to
+ * a new visit object. If it isn't modified
+ * Piwik uses the default class.
+ */
+ Piwik::postEvent('Tracker.makeNewVisitObject', array(&$visit));
+
+ if (is_null($visit)) {
+ $visit = new Visit();
+ } elseif (!($visit instanceof VisitInterface)) {
+ throw new Exception("The Visit object set in the plugin must implement VisitInterface");
+ }
+
+ return $visit;
+ }
+}