* @package WB * @subpackage base */ WBClass::load('WBEvent_Handler' , 'WBEvent_Handler_Contact' ); /** * WBEvent_Handler_Contact_Saver * * Store contact data * * @version 0.1.2 * @package Wombat * @subpackage base */ class WBEvent_Handler_Contact_Saver extends WBEvent_Handler_Contact { /** * Handler config * * * @var array */ protected $config = array( 'namespace' => 'default', 'xid' => 0, 'xidindex' => '' ); /** * @var WBDatasource_ContactRequest */ private $cr; /** * constructor * */ public function __construct() { $this->cr = WBClass::create('WBDatasource_ContactRequest'); } /** * Store Contact Request * * @see isRecoverable() * @param WBEvent $e * @return bool true to continue, false to stop processing * @throws Exception in case of error */ public function process(WBEvent $e) { $man = $this->cr->getMandator(); if ($man->isEnabled()) { $mid = $e->get($man->getIdentifier()); $man->setId($mid); } $this->cr->setNamespace($this->config['namespace']); $data = $e->get(); // copy user id if (empty($data['uid']) && isset($data['user'])) { $data['uid'] = $data['user']; } $data['xid'] = $this->config['xid']; if (!empty($this->config['xidindex'])) { $data['xid'] = $e->get($this->config['xidindex'], 0); } $id = $this->cr->add($data); $e->set('contactrequest', $id); return true; } }