mirror of
https://github.com/Mibew/mibew.git
synced 2025-03-23 02:21:23 +03:00
Create "visitorCreate" event
This commit is contained in:
parent
e61b91dd5e
commit
de1d5d6d51
@ -156,6 +156,18 @@ final class Events
|
|||||||
*/
|
*/
|
||||||
const RESOURCE_NOT_FOUND = 'resourceNotFound';
|
const RESOURCE_NOT_FOUND = 'resourceNotFound';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visitor is created.
|
||||||
|
*
|
||||||
|
* This event is triggered when a visitor is tracked by the widget for the
|
||||||
|
* first time. An associative array with the following items is passed to
|
||||||
|
* the event handlers:
|
||||||
|
* - "visitor": array, list of visitor's info. See returned value of
|
||||||
|
* {@link track_get_visitor_by_id()} function for details of its
|
||||||
|
* structure.
|
||||||
|
*/
|
||||||
|
const VISITOR_CREATE = 'visitorCreate';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visitor is tracked by the system.
|
* Visitor is tracked by the system.
|
||||||
*
|
*
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Import namespaces and classes of the core
|
// Import namespaces and classes of the core
|
||||||
|
use Mibew\EventDispatcher\EventDispatcher;
|
||||||
|
use Mibew\EventDispatcher\Events;
|
||||||
use Mibew\Database;
|
use Mibew\Database;
|
||||||
use Mibew\Settings;
|
use Mibew\Settings;
|
||||||
use Mibew\Thread;
|
use Mibew\Thread;
|
||||||
@ -45,6 +47,16 @@ function track_visitor($visitor_id, $entry, $referer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize visitor tracknig.
|
||||||
|
*
|
||||||
|
* Triggers {@link \Mibew\EventDispatcher\Events::VISITOR_CREATE} event.
|
||||||
|
*
|
||||||
|
* @param string $entry The page the visitor came from to the page with
|
||||||
|
* tracking code.
|
||||||
|
* @param string $referer The page where tracking code is placed.
|
||||||
|
* @return int ID of the visitor.
|
||||||
|
*/
|
||||||
function track_visitor_start($entry, $referer)
|
function track_visitor_start($entry, $referer)
|
||||||
{
|
{
|
||||||
$visitor = visitor_from_request();
|
$visitor = visitor_from_request();
|
||||||
@ -71,6 +83,9 @@ function track_visitor_start($entry, $referer)
|
|||||||
track_visit_page($id, $referer);
|
track_visit_page($id, $referer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$args = array('visitor' => track_get_visitor_by_id($id));
|
||||||
|
EventDispatcher::getInstance()->triggerEvent('visitorCreate', $args);
|
||||||
|
|
||||||
return $id ? $id : 0;
|
return $id ? $id : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user