web/lib/Zend/Cloud/Infrastructure/Factory.php
author Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
Thu, 07 May 2015 15:16:02 +0200
changeset 1230 68c69c656a2c
parent 808 6b6c2214f778
permissions -rw-r--r--
upgrade Zend
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
808
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     1
<?php
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     2
/**
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     3
 * @category   Zend
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     4
 * @package    Zend_Cloud
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     5
 * @subpackage Infrastructure
1230
68c69c656a2c upgrade Zend
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 808
diff changeset
     6
 * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
808
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     7
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     8
 */
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     9
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    10
require_once 'Zend/Cloud/AbstractFactory.php';
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    11
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    12
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    13
/**
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    14
 * Factory for infrastructure adapters
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    15
 * 
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    16
 * @package    Zend_Cloud
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    17
 * @subpackage Infrastructure
1230
68c69c656a2c upgrade Zend
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 808
diff changeset
    18
 * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
808
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    19
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    20
 */
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    21
class Zend_Cloud_Infrastructure_Factory extends Zend_Cloud_AbstractFactory
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    22
{
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    23
    const INFRASTRUCTURE_ADAPTER_KEY = 'infrastructure_adapter';
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    24
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    25
    /**
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    26
     * @var string Interface which adapter must implement to be considered valid
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    27
     */
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    28
    protected static $_adapterInterface = 'Zend_Cloud_Infrastructure_Adapter';
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    29
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    30
    /**
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    31
     * Constructor
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    32
     *
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    33
     * Private ctor - should not be used
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    34
     *
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    35
     * @return void
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    36
     */
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    37
    private function __construct()
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    38
    {
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    39
    }
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    40
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    41
    /**
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    42
     * Retrieve an adapter instance
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    43
     *
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    44
     * @param  array $options
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    45
     * @return void
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    46
     */
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    47
    public static function getAdapter($options = array())
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    48
    {
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    49
        $adapter = parent::_getAdapter(self::INFRASTRUCTURE_ADAPTER_KEY, $options);
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    50
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    51
        if (!$adapter) {
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    52
            require_once 'Zend/Cloud/Infrastructure/Exception.php';
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    53
            throw new Zend_Cloud_Infrastructure_Exception(sprintf(
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    54
                'Class must be specified using the "%s" key',
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    55
                self::INFRASTRUCTURE_ADAPTER_KEY
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    56
            ));
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    57
        } elseif (!$adapter instanceof self::$_adapterInterface) {
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    58
            require_once 'Zend/Cloud/Infrastructure/Exception.php';
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    59
            throw new Zend_Cloud_Infrastructure_Exception(sprintf(
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    60
                'Adapter must implement "%s"', self::$_adapterInterface
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    61
            ));
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    62
        }
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    63
        return $adapter;
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    64
    }
6b6c2214f778 update Zend and twitter oauth end point
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    65
}