1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/lib/Doctrine/Record/Abstract.php

156 lines
4.0 KiB
PHP
Raw Normal View History

2007-06-27 20:59:23 +04:00
<?php
/*
* $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
* <http://www.phpdoctrine.org>.
2007-06-27 20:59:23 +04:00
*/
Doctrine::autoload('Doctrine_Access');
/**
* Doctrine_Record_Abstract
*
* @package Doctrine
* @subpackage Record
2007-06-27 20:59:23 +04:00
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
abstract class Doctrine_Record_Abstract extends Doctrine_Access
{
2007-08-03 15:52:24 +04:00
/**
2008-02-13 13:53:07 +03:00
* The metadata container that describes the entity class.
*
* @param Doctrine_ClassMetadata
2007-08-03 15:52:24 +04:00
*/
protected $_table;
/**
*
2008-02-13 13:53:07 +03:00
* @var Doctrine_Mapper
*/
protected $_mapper;
/**
* @deprecated
*/
2007-11-28 03:01:03 +03:00
public function setTableDefinition()
{}
/**
* @deprecated
*/
2007-11-28 03:01:03 +03:00
public function setUp()
{}
2007-11-28 03:01:03 +03:00
2007-11-27 01:27:23 +03:00
/**
* getTable
2008-02-08 01:21:18 +03:00
* returns the table object for this record
2007-11-27 01:27:23 +03:00
*
2008-02-08 01:21:18 +03:00
* @return Doctrine_Table a Doctrine_Table object
* @deprecated
2007-11-27 01:27:23 +03:00
*/
public function getTable()
2008-02-08 01:21:18 +03:00
{
return $this->getClassMetadata();
}
/**
* Gets the ClassMetadata object that describes the entity class.
*/
public function getClassMetadata()
2007-11-27 01:27:23 +03:00
{
return $this->_table;
}
/**
* Returns the mapper of the entity.
2008-02-13 13:53:07 +03:00
*
* @return Doctrine_Mapper
*/
public function getMapper()
{
return $this->_mapper;
}
2007-06-27 20:59:23 +04:00
/**
* addListener
*
* @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener
* @return Doctrine_Record
*/
public function addListener($listener, $name = null)
{
$this->_table->addRecordListener($listener, $name = null);
2007-06-27 20:59:23 +04:00
return $this;
}
2007-06-27 20:59:23 +04:00
/**
* getListener
*
* @return Doctrine_EventListener_Interface|Doctrine_Overloadable
*/
public function getListener()
{
return $this->_table->getRecordListener();
2007-06-27 20:59:23 +04:00
}
2007-06-27 20:59:23 +04:00
/**
* setListener
*
* @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener
* @return Doctrine_Record
*/
public function setListener($listener)
{
$this->_table->setRecordListener($listener);
2007-06-27 20:59:23 +04:00
return $this;
}
public function setAttribute($attr, $value)
{
$this->_table->setAttribute($attr, $value);
}
/**
* attribute
* sets or retrieves an option
*
* @see Doctrine::ATTR_* constants availible attributes
* @param mixed $attr
* @param mixed $value
* @return mixed
*/
public function attribute($attr, $value)
{
if ($value == null) {
if (is_array($attr)) {
foreach ($attr as $k => $v) {
$this->_table->setAttribute($k, $v);
}
} else {
return $this->_table->getAttribute($attr);
}
} else {
$this->_table->setAttribute($attr, $value);
}
}
2007-10-06 00:28:08 +04:00
}