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
|
2008-01-23 01:52:53 +03:00
|
|
|
* <http://www.phpdoctrine.org>.
|
2007-06-27 20:59:23 +04:00
|
|
|
*/
|
|
|
|
Doctrine::autoload('Doctrine_Access');
|
|
|
|
/**
|
|
|
|
* Doctrine_Record_Abstract
|
|
|
|
*
|
2007-10-04 01:43:22 +04:00
|
|
|
* @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
|
2008-02-22 21:11:35 +03:00
|
|
|
* @link www.phpdoctrine.org
|
2007-06-27 20:59:23 +04:00
|
|
|
* @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-14 23:20:35 +03:00
|
|
|
|
2008-01-05 22:55:56 +03:00
|
|
|
/**
|
|
|
|
*
|
2008-02-13 13:53:07 +03:00
|
|
|
* @var Doctrine_Mapper
|
2008-01-05 22:55:56 +03:00
|
|
|
*/
|
|
|
|
protected $_mapper;
|
2008-02-14 23:20:35 +03:00
|
|
|
|
2008-02-04 00:29:57 +03:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
2007-11-28 03:01:03 +03:00
|
|
|
public function setTableDefinition()
|
2008-02-04 00:29:57 +03:00
|
|
|
{}
|
2008-02-14 23:20:35 +03:00
|
|
|
|
2008-02-04 00:29:57 +03:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
2007-11-28 03:01:03 +03:00
|
|
|
public function setUp()
|
2008-02-04 00:29:57 +03:00
|
|
|
{}
|
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;
|
|
|
|
}
|
2008-02-14 23:20:35 +03:00
|
|
|
|
2008-02-04 00:29:57 +03:00
|
|
|
/**
|
|
|
|
* Returns the mapper of the entity.
|
2008-02-13 13:53:07 +03:00
|
|
|
*
|
|
|
|
* @return Doctrine_Mapper
|
2008-02-04 00:29:57 +03:00
|
|
|
*/
|
2008-01-05 22:55:56 +03:00
|
|
|
public function getMapper()
|
|
|
|
{
|
|
|
|
return $this->_mapper;
|
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
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)
|
|
|
|
{
|
2007-07-11 18:39:15 +04:00
|
|
|
$this->_table->addRecordListener($listener, $name = null);
|
2007-06-27 20:59:23 +04:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-06-27 20:59:23 +04:00
|
|
|
/**
|
|
|
|
* getListener
|
|
|
|
*
|
|
|
|
* @return Doctrine_EventListener_Interface|Doctrine_Overloadable
|
|
|
|
*/
|
|
|
|
public function getListener()
|
|
|
|
{
|
2007-07-11 18:39:15 +04:00
|
|
|
return $this->_table->getRecordListener();
|
2007-06-27 20:59:23 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +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)
|
|
|
|
{
|
2007-07-11 18:39:15 +04:00
|
|
|
$this->_table->setRecordListener($listener);
|
2007-06-27 20:59:23 +04:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2008-02-14 23:20:35 +03:00
|
|
|
|
2008-02-04 00:29:57 +03:00
|
|
|
public function setAttribute($attr, $value)
|
|
|
|
{
|
|
|
|
$this->_table->setAttribute($attr, $value);
|
|
|
|
}
|
2008-02-14 23:20:35 +03:00
|
|
|
|
2008-02-04 00:29:57 +03:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
}
|
2008-02-14 23:20:35 +03:00
|
|
|
|
2007-10-06 00:28:08 +04:00
|
|
|
}
|