factory.php 742 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
<?php namespace Laravel\Session\Drivers;

use Laravel\Cache\Manager as Cache;

class Factory {

	/**
	 * Create a new session driver instance.
	 *
	 * @param  string  $driver
	 * @return Driver
	 */
	public static function make($driver)
	{
		switch ($driver)
		{
			case 'apc':
				return new APC(Cache::driver('apc'));

			case 'cookie':
				return new Cookie;

			case 'database':
				return new Database(\Laravel\Database\Manager::connection());

			case 'file':
				return new File(SESSION_PATH);

			case 'memcached':
				return new Memcached(Cache::driver('memcached'));

			case 'redis':
				return new Redis(Cache::driver('redis'));

			default:
Phill Sparks committed
36
				throw new \DomainException("Session driver [$driver] is not supported.");
37 38 39
		}
	}

Phill Sparks committed
40
}