added Doctrine_Record::state()
This commit is contained in:
parent
7e7a0b879c
commit
0c0e6fd637
@ -499,6 +499,38 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
final public function getState() {
|
||||
return $this->_state;
|
||||
}
|
||||
/**
|
||||
* state
|
||||
* returns / assigns the state of this record
|
||||
*
|
||||
* @param integer|string $state if set, this method tries to set the record state to $state
|
||||
*
|
||||
* @throws Doctrine_Record_State_Exception if trying to set an unknown state
|
||||
* @return null|integer
|
||||
*/
|
||||
public function state($state = null) {
|
||||
if($state == null) {
|
||||
return $this->_state;
|
||||
}
|
||||
if(is_integer($state)) {
|
||||
if($state >= 1 && $state <= 6)
|
||||
$this->_state = $state;
|
||||
} elseif(is_string($state)) {
|
||||
$upper = strtoupper($state);
|
||||
switch($upper) {
|
||||
case 'DIRTY':
|
||||
case 'CLEAN':
|
||||
case 'TDIRTY':
|
||||
case 'TCLEAN':
|
||||
case 'PROXY':
|
||||
case 'DELETED':
|
||||
$this->_state = constant('Doctrine_Record::STATE_' . $upper);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Doctrine_Record_State_Exception('Unknown record state ' . $state);
|
||||
}
|
||||
/**
|
||||
* refresh
|
||||
* refresh internal data from the database
|
||||
|
@ -1,5 +1,29 @@
|
||||
<?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.com>.
|
||||
*/
|
||||
Doctrine::autoload('Doctrine_Exception');
|
||||
|
||||
class Doctrine_Record_Exception extends Doctrine_Exception { }
|
||||
|
||||
/**
|
||||
* Doctrine_Exception
|
||||
*
|
||||
* @package Doctrine ORM
|
||||
* @url www.phpdoctrine.com
|
||||
* @license LGPL
|
||||
*/
|
||||
class Doctrine_Record_Exception extends Doctrine_Exception { }
|
||||
|
29
lib/Doctrine/Record/State/Exception.php
Normal file
29
lib/Doctrine/Record/State/Exception.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?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.com>.
|
||||
*/
|
||||
Doctrine::autoload('Doctrine_Record_Exception');
|
||||
/**
|
||||
* Doctrine_Exception
|
||||
*
|
||||
* @package Doctrine ORM
|
||||
* @url www.phpdoctrine.com
|
||||
* @license LGPL
|
||||
*/
|
||||
class Doctrine_Record_State_Exception extends Doctrine_Record_Exception { }
|
Loading…
Reference in New Issue
Block a user