* @license PHP License * @package WB * @subpackage eventHandler */ WBClass::load('WBEvent_Handler'); /** * WBEvent_Handler_Table * * @version 0.2.0 * @package Wombat * @subpackage eventHandler */ class WBEvent_Handler_Table extends WBEvent_Handler { /** * Table access * @var WBDatasource_Table */ protected $table; /** * List of Required Configuration Parmaters * * @var array */ protected $configRequired = array(); /** * Initialize Table Object * * @see config */ protected function startTable() { if (!empty($this->table)) { return; } $params = array(); if (!empty($this->config['dbconfig'])) { $params['dbconfig'] = $this->config['dbconfig']; } $this->table = WBClass::create('WBDatasource_Table', $params); } /** * Get Value From Config or Event-Data * * @param WBEvent * @param string * @param bool * @return string */ protected function get4ConfigOrData(WBEvent $e, $name, $required = true) { $key = $this->config[$name]; if (empty($key) && !empty($this->config[$name . 'index'])) { $key = $e->get($this->config[$name . 'index']); } if ($required && empty($key)) { WBClass::load('WBException_Config'); throw new WBException_Config(sprintf('%s may not be empty', $key), 2, get_class($this)); } return $key; } /** * Check Config * * @throws WBException_Config */ protected function verifyConfig() { foreach ($this->configRequired as $c) { if (empty($this->config[$c])) { WBClass::load('WBException_Config'); throw new WBException_Config(sprintf('Configuration parameter %s must not be empty!', $c), 1, get_class($this)); } } } }