* @package tao */ abstract class tao_helpers_data_GenerisAdapter { /** * Short description of attribute options * * @access protected * @var array */ protected $options = []; /** * List of validators applied during importing to data * @var array */ protected $validators = []; /** * @var array */ protected $errorMessages = []; // --- OPERATIONS --- /** * Short description of method __construct * * @access public * @author Bertrand Chevrier, * @param array $options * @return mixed */ public function __construct($options = []) { $this->options = $options; } /** * get the adapter options * * @access public * @author Bertrand Chevrier, * @return array */ public function getOptions() { $returnValue = []; $returnValue = $this->options; return (array) $returnValue; } /** * set the adapter options * * @access public * @author Bertrand Chevrier, * @param array $options * @return mixed */ public function setOptions($options = []) { $this->options = $options; } /** * add a new option * * @access public * @author Bertrand Chevrier, * @param string $name * @param mixed $value * @return mixed */ public function addOption($name, $value) { $this->options[$name] = $value; } /** * import prototype: import the source into the destination class * * @abstract * @access public * @author Bertrand Chevrier, * @param string $source * @param core_kernel_classes_Class $destination * @return boolean */ abstract public function import($source, core_kernel_classes_Class $destination = null); /** * export prototype: export the source class * * @abstract * @access public * @author Bertrand Chevrier, * @param core_kernel_classes_Class $source * @return string */ abstract public function export(core_kernel_classes_Class $source = null); /** * @return array */ public function getValidators() { return $this->validators; } /** * @param $target * @return array */ public function getValidator($target) { return isset($this->validators[$target]) ? $this->validators[$target] : []; } /** * @param array $validators */ public function setValidators($validators) { $this->validators = $validators; } /** * @return array */ public function getErrorMessages() { return $this->errorMessages; } /** * @param string $target * @param common_report_Report $message */ public function addErrorMessage($target, $message) { if (is_string($target)) { $this->errorMessages[$target][] = $message; } } /** * @return boolean */ public function hasErrors() { return count($this->getErrorMessages()) > 0; } }