D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
psa
/
admin
/
plib
/
modules
/
advisor
/
vendor
/
tedivm
/
stash
/
src
/
Stash
/
Filename :
DriverList.php
back
Copy
<?php /* * This file is part of the Stash package. * * (c) Robert Hafner <tedivm@tedivm.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace PleskAdvisor\Stash; /** * DriverList contains various functions used to organize Driver classes that are available in the system. * * @package Stash * @author Robert Hafner <tedivm@tedivm.com> */ class DriverList { /** * An array of possible cache storage data methods, with the driver class as the array value. * * @var array */ protected static $drivers = array('Apc' => 'PleskAdvisor\\Stash\\Driver\\Apc', 'BlackHole' => 'PleskAdvisor\\Stash\\Driver\\BlackHole', 'Composite' => 'PleskAdvisor\\Stash\\Driver\\Composite', 'Ephemeral' => 'PleskAdvisor\\Stash\\Driver\\Ephemeral', 'FileSystem' => 'PleskAdvisor\\Stash\\Driver\\FileSystem', 'Memcache' => 'PleskAdvisor\\Stash\\Driver\\Memcache', 'Redis' => 'PleskAdvisor\\Stash\\Driver\\Redis', 'SQLite' => 'PleskAdvisor\\Stash\\Driver\\Sqlite'); /** * Returns a list of cache drivers that are also supported by this system. * * @return array Driver Name => Class Name */ public static function getAvailableDrivers() { $availableDrivers = array(); $allDrivers = self::getAllDrivers(); foreach ($allDrivers as $name => $class) { if ($name == 'Composite') { $availableDrivers[$name] = $class; } else { if ($class::isAvailable()) { $availableDrivers[$name] = $class; } } } return $availableDrivers; } /** * Returns a list of all registered cache drivers, regardless of system support. * * @return array Driver Name => Class Name */ public static function getAllDrivers() { $driverList = array(); foreach (self::$drivers as $name => $class) { if (!\class_exists($class) || !\in_array('PleskAdvisor\\Stash\\Interfaces\\DriverInterface', \class_implements($class))) { continue; } $driverList[$name] = $class; } return $driverList; } /** * Registers a new driver. * * @param string $name * @param string $class */ public static function registerDriver($name, $class) { self::$drivers[$name] = $class; } /** * Returns the driver class for a specific driver name. * * @param string $name * @return bool */ public static function getDriverClass($name) { if (!isset(self::$drivers[$name])) { return \false; } return self::$drivers[$name]; } }