* @license GPLv2 * @package generis * */ use \oat\generis\Helper\UuidPrimaryKeyTrait; abstract class common_persistence_Persistence { use UuidPrimaryKeyTrait; /** * Driver of the persistence * * @var common_persistence_Driver */ private $driver; /** * Persistence parameters * * @var array */ private $params = []; public static function getPersistence($driverId) { $returnValue = common_persistence_Manager::getPersistence($driverId); $class = get_called_class(); if (!$returnValue instanceof $class) { common_Logger::w('Got a ', get_class($returnValue) . ' instead of ' . $class); } return $returnValue; } /** * Constructor * * @access public * @author "Lionel Lecaque, " * @param array $params * @param common_persistence_driver $driver */ public function __construct($params = [], common_persistence_driver $driver) { $this->setParams($params); $this->setDriver($driver); } /** * Retrieve persistence's driver * * @access public * @author "Lionel Lecaque, " * @return common_persistence_driver */ public function getDriver() { return $this->driver; } /** * Set the persistence * * @access protected * @author "Lionel Lecaque, " * @param common_persistence_Driver $driver */ protected function setDriver(common_persistence_Driver $driver) { $this->driver = $driver; } /** * Retrieve persistence's parameters * * @access protected * @author "Lionel Lecaque, " * @return array: */ protected function getParams() { return $this->params; } /** * set persistence's parameters * * @access protected * @author "Lionel Lecaque, " * @param array $params */ protected function setParams($params) { $this->params = $params; } }