Module.php 2.62 KB
Newer Older
zYne's avatar
zYne committed
1
<?php
lsmith's avatar
lsmith committed
2
/*
zYne's avatar
zYne committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *  $Id$
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the LGPL. For more information, see
19
 * <http://www.phpdoctrine.org>.
zYne's avatar
zYne committed
20
 */
21

zYne's avatar
zYne committed
22 23 24 25
/**
 * Doctrine_Connection_Module
 *
 * @package     Doctrine
26
 * @subpackage  Connection
zYne's avatar
zYne committed
27 28 29 30 31 32
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
 * @link        www.phpdoctrine.com
 * @since       1.0
 * @version     $Revision$
 * @author      Konsta Vesterinen <kvesteri@cc.hut.fi>
 */
lsmith's avatar
lsmith committed
33 34
class Doctrine_Connection_Module
{
zYne's avatar
zYne committed
35
    /**
lsmith's avatar
lsmith committed
36
     * @var Doctrine_Connection $conn       Doctrine_Connection object, every connection
zYne's avatar
zYne committed
37 38 39
     *                                      module holds an instance of Doctrine_Connection
     */
    protected $conn;
40

zYne's avatar
zYne committed
41 42 43 44
    /**
     * @var string $moduleName              the name of this module
     */
    protected $moduleName;
45

zYne's avatar
zYne committed
46 47 48 49
    /**
     * @param Doctrine_Connection $conn     Doctrine_Connection object, every connection
     *                                      module holds an instance of Doctrine_Connection
     */
lsmith's avatar
lsmith committed
50 51
    public function __construct($conn = null)
    {
lsmith's avatar
lsmith committed
52
        if ( ! ($conn instanceof Doctrine_Connection)) {
53
            $conn = Doctrine_Manager::getInstance()->getCurrentConnection();
lsmith's avatar
lsmith committed
54
        }
zYne's avatar
zYne committed
55
        $this->conn = $conn;
lsmith's avatar
lsmith committed
56

zYne's avatar
zYne committed
57 58 59 60
        $e = explode('_', get_class($this));

        $this->moduleName = $e[1];
    }
61

zYne's avatar
zYne committed
62 63 64 65 66 67
    /**
     * getConnection
     * returns the connection object this module uses
     *
     * @return Doctrine_Connection
     */
lsmith's avatar
lsmith committed
68 69
    public function getConnection()
    {
zYne's avatar
zYne committed
70 71
        return $this->conn;
    }
72

zYne's avatar
zYne committed
73 74 75 76 77 78
    /**
     * getModuleName
     * returns the name of this module
     *
     * @return string       the name of this module
     */
lsmith's avatar
lsmith committed
79 80
    public function getModuleName()
    {
lsmith's avatar
lsmith committed
81
        return $this->moduleName;
zYne's avatar
zYne committed
82
    }
83
}