Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VisitorFactory.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Piwik - free/libre analytics platform
  4. *
  5. * @link http://piwik.org
  6. * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
  7. *
  8. */
  9. namespace Piwik\Plugins\Live;
  10. use Exception;
  11. use Piwik\Piwik;
  12. class VisitorFactory
  13. {
  14. /**
  15. * Returns Visitor object.
  16. * This method can be overwritten to use a different Visitor object
  17. *
  18. * @param array $visitorRawData
  19. * @throws \Exception
  20. * @return \Piwik\Plugins\Live\VisitorInterface
  21. * @ignore
  22. */
  23. public function create(array $visitorRawData = array())
  24. {
  25. $visitor = null;
  26. /**
  27. * Triggered while visit is filtering in live plugin. Subscribers to this
  28. * event can force the use of a custom visitor object that extends from
  29. * {@link Piwik\Plugins\Live\VisitorInterface}.
  30. *
  31. * @param \Piwik\Plugins\Live\VisitorInterface &$visitor Initialized to null, but can be set to
  32. * a new visitor object. If it isn't modified
  33. * Piwik uses the default class.
  34. * @param array $visitorRawData Raw data using in Visitor object constructor.
  35. */
  36. Piwik::postEvent('Live.makeNewVisitorObject', array(&$visitor, $visitorRawData));
  37. if (is_null($visitor)) {
  38. $visitor = new Visitor($visitorRawData);
  39. } elseif (!($visitor instanceof VisitorInterface)) {
  40. throw new Exception("The Visitor object set in the plugin must implement VisitorInterface");
  41. }
  42. return $visitor;
  43. }
  44. }