/** * Returns Cache engine object out of an engine name * * @param string|array $engineName Name of the engine * @return \CoreTyson\Cache\Engine\AbstractCacheEngine engine instance */ private static function _build($engineName) { $engine = new $engineName(); if (!$engine instanceof AbstractCacheEngine) { throw new \RuntimeException('Cache engine must extend AbstractCacheEngine class.'); } static::$_engine = $engine; return static::$_engine; }
/** * Returns session engine object out of a engine name * * @param string|array $engine Name of the Session engine * @return \CoreTyson\Mailer\Transport\AbstractTransport transport instance * @throws \CoreTyson\Mailer\Exception\MissingTransport If transport class not found */ public static function register($engine) { $engineName = "\\" . __NAMESPACE__ . "\\Engine\\" . $engine . "Engine"; if (class_exists($engineName, false)) { throw new \RuntimeException(sprintf('Session engine class "%s" was not found.', $engine . "Engine")); } $engine = new $engineName(); if (!$engine instanceof SessionHandlerInterface) { throw new \RuntimeException('Session engine must implements SessionHandlerInterface class.'); } static::$_engine = $engine; session_set_save_handler(static::$_engine); return static::$_engine; }
public final function __construct() { if (!static::$_driver) { $class = 'dioxid\\model\\engine\\' . Config::getVal('database', 'driver', true) . 'Engine'; } else { $class = 'dioxid\\model\\engine\\' . static::$_driver . 'Engine'; } if (class_exists($class)) { static::$_engine = call_user_func_array(array($class, 'getInstance'), array(static::$_name)); } else { throw new EngineNotFoundException($class . ' not found'); } static::_init(); }
/** * Get the crypto implementation based on the loaded extensions. * * You can use this method to forcibly decide between mcrypt/openssl/custom implementations. * * @param AbstractEncryptEngine|string|null $engine The crypto engine to use. * @return AbstractEncryptEngine Crypto instance. * @throws \InvalidArgumentException When no compatible crypto extension is available. */ public static function engine($engine = null) { if ($engine === null && static::$_engine === null) { if (extension_loaded('openssl')) { $engine = new OpenSslEngine(); } elseif (extension_loaded('mcrypt')) { $engine = new MCryptEngine(); } } if (is_string($engine)) { $engine = Core::className($engine, "Util/CrypTyson", "Engine"); $eng = new $engine(); if ($eng instanceof AbstractEncryptEngine) { static::$_engine = $eng; } } if ($engine instanceof AbstractEncryptEngine) { static::$_engine = $engine; } if (isset(static::$_engine)) { return static::$_engine; } throw new InvalidArgumentException('No compatible crypto engine available. ' . 'Load either the openssl or mcrypt extensions'); }