Created
October 17, 2012 20:13
-
-
Save alzerid/3907851 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*******************************/ | |
/** Marketing specific Events **/ | |
/*******************************/ | |
class MarketingLogEvent extends LogEvent | |
{ | |
protected $_description; | |
protected $_kind_append; | |
public function __construct() | |
{ | |
$name = trim(preg_replace('/([a-z0-9])?([A-Z])/', '$1 $2', get_called_class())); | |
$this->_description = $name; | |
$this->_kind_append = strtolower(preg_replace('/ /', '.', $name)); | |
} | |
public function toLogArray() | |
{ | |
$vars = get_class_vars(get_class($this)); | |
$fields = array('_routing_key' => $this->_routing_key); | |
foreach($vars as $key=>$val) | |
{ | |
if(preg_match('/^_v_/', $key)) | |
{ | |
$fkey = preg_replace('/^_v_/', '', $key); | |
$fields[$fkey] = $this->$key; | |
} | |
} | |
//Merge array | |
return array_merge($fields, $this->_metaData); | |
} | |
} | |
class MarketingCallcenterEvent extends MarketingLogevent | |
{ | |
private static $_EVENTS = array('call'); | |
protected $_v_center; //The call center we are contacting | |
protected $_v_event; //The event | |
public function __construct($center, $event) | |
{ | |
//call parent | |
parent::__construct(); | |
//Ensure $event is in $_EVENTS | |
if(!in_array($event, self::$_EVENTS)) | |
throw new Exception("$event is not a valid event."); | |
//Set variables | |
$this->_v_event = $event; | |
$this->_v_center = $center; | |
} | |
} | |
/** Called when we post buyer information requests **/ | |
class MarketingBuyerEvent extends MarketingLogevent | |
{ | |
private static $_EVENTS = array('listing'); | |
protected $_v_buyer; //The call center we are contacting | |
protected $_v_event; //The event | |
public function __construct($buyer, $event) | |
{ | |
//Ensure $event is in $_EVENTS | |
if(!in_array($event, self::$_EVENTS)) | |
throw new Exception("$event is not a valid event."); | |
//Set variables | |
$this->_v_buyer = $buyer; | |
$this->_v_event = $event; | |
} | |
} | |
/***********************************/ | |
/** End Marketing specific Events **/ | |
/***********************************/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment