/** * @return ChangeFile * @throws Exception */ public final function getPersistentBackend() { $backend = $this->settings->getChangeBackend(); if ($backend == 'file') { return new ChangeFile($this->settings); } throw new Exception('No suitable backend found for type "' . $backend . '"'); }
/** * Gets the directory relative to DOC_ROOT * @param string $dirname * @return string * @throws Exception */ protected function getDir($dirname = '') { $dir = realpath($this->settings->getDocRoot() . (!empty($dirname) ? $dirname : '')); if (substr($dir, 0, -1) != '/') { $dir .= '/'; } if (!$dir) { throw new Exception('Directory "' . $dir . '" not found.'); } return $dir; }
/** * @return CacheFile * @throws Exception */ public final function getPersistentBackend() { $backend = $this->settings->getCacheBackend(); if ($backend == 'file') { return new CacheFile($this->settings); } else { if ($backend == 'db') { return new CacheDb($this->settings); } } throw new Exception('No suitable caching backend found for type "' . $backend . '"'); }
public function __construct(DbChangesSettings $settings) { $this->settings = $settings; $dbConn = $settings->getDbConn('cache'); //if there is no cache connection use the standard one if (empty($dbConn)) { $dbConn = $settings->getDbConn('standard'); } parent::__construct($dbConn); //check table if (isset($dbConn['cache_table'])) { $this->cacheTable = (string) $dbConn['cache_table']; } //$this->checkCacheTable(); }
/** * Singleton Factory method * @static * @return DbChangesSettings */ public static function getInstance() { if (is_null(self::$instance)) { self::$instance = new DbChangesSettings(); } return self::$instance; }
* Created by JetBrains PhpStorm. * User: georgroesch * Date: 04.09.12 * Time: 21:30 */ //be as verbose as possible error_reporting(E_ALL | E_STRICT); if (!defined('DBC_EXECUTION_MODE')) { define('DBC_EXECUTION_MODE', 'web'); } $return = array('status' => 'ok'); spl_autoload_register(function ($class) { require_once dirname(__FILE__) . '/lib/' . $class . '.class.php'; }); try { $settings = DbChangesSettings::getInstance(); $changeFactory = new ChangeFactory($settings, new CacheFactory($settings)); if (!isset($_REQUEST['action'])) { throw new Exception('No action given.'); } $command = $_REQUEST['action']; if (isset($_REQUEST['cli_args']) && DBC_EXECUTION_MODE == 'cli') { $_REQUEST = $_REQUEST['cli_args']; } $className = 'Action' . ucfirst($command); if (!file_exists(dirname(__FILE__) . '/lib/' . $className . '.class.php')) { throw new Exception('Class "' . $className . '" does not exist.'); } if (!is_readable(dirname(__FILE__) . '/lib/' . $className . '.class.php')) { throw new Exception('Class "' . $className . '" is not readable.'); }
public function isExecutable() { return $this->isExecuted !== true && (DbConnection::canExecuteSuper($this->settings->getDbConn($this->getDb())) || $this->rights != 'super'); }