~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Memory.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * Zend Framework
 
4
 *
 
5
 * LICENSE
 
6
 *
 
7
 * This source file is subject to the new BSD license that is bundled
 
8
 * with this package in the file LICENSE.txt.
 
9
 * It is also available through the world-wide-web at this URL:
 
10
 * http://framework.zend.com/license/new-bsd
 
11
 * If you did not receive a copy of the license and are unable to
 
12
 * obtain it through the world-wide-web, please send an email
 
13
 * to license@zend.com so we can send you a copy immediately.
 
14
 *
 
15
 * @package    Zend_Memory
 
16
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
17
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
18
 */
 
19
 
 
20
/** Zend_Memory_Exception */
 
21
require_once 'Zend/Memory/Manager.php';
 
22
 
 
23
/** Zend_Memory_Exception */
 
24
require_once 'Zend/Memory/Exception.php';
 
25
 
 
26
/** Zend_Memory_Value */
 
27
require_once 'Zend/Memory/Value.php';
 
28
 
 
29
/** Zend_Memory_Container */
 
30
require_once 'Zend/Memory/Container.php';
 
31
 
 
32
/** Zend_Memory_Exception */
 
33
require_once 'Zend/Cache.php';
 
34
 
 
35
 
 
36
/**
 
37
 * @category   Zend
 
38
 * @package    Zend_Memory
 
39
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
40
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
41
 */
 
42
class Zend_Memory
 
43
{
 
44
    /**
 
45
     * Factory
 
46
     *
 
47
     * @param string $backend backend name
 
48
     * @param array $backendOptions associative array of options for the corresponding backend constructor
 
49
     * @return Zend_Memory_Manager
 
50
     * @throws Zend_Memory_Exception
 
51
     */
 
52
    public static function factory($backend, $backendOptions = array())
 
53
    {
 
54
        if (strcasecmp($backend, 'none') == 0) {
 
55
            return new Zend_Memory_Manager();
 
56
        }
 
57
 
 
58
        // because lowercase will fail
 
59
        $backend = @ucfirst(strtolower($backend));
 
60
 
 
61
        if (!in_array($backend, Zend_Cache::$availableBackends)) {
 
62
            throw new Zend_Memory_Exception("Incorrect backend ($backend)");
 
63
        }
 
64
 
 
65
        $backendClass = 'Zend_Cache_Backend_' . $backend;
 
66
 
 
67
        // For perfs reasons, we do not use the Zend_Loader::loadClass() method
 
68
        // (security controls are explicit)
 
69
        require_once str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php';
 
70
 
 
71
        $backendObject = new $backendClass($backendOptions);
 
72
 
 
73
        return new Zend_Memory_Manager($backendObject);
 
74
    }
 
75
}