1
0
mirror of synced 2024-12-13 14:56:01 +03:00

moved entity/entitymanager exceptions

This commit is contained in:
romanb 2008-09-12 09:37:05 +00:00
parent e69034fc25
commit 93b2cb0a58
6 changed files with 5 additions and 130 deletions

View File

@ -453,7 +453,7 @@ abstract class Doctrine_Entity implements ArrayAccess, Serializable
}
}
} else {
throw Doctrine_Entity_Exception::invalidField($fieldName);
throw Doctrine_ORM_Exceptions_EntityException::invalidField($fieldName);
}
}

View File

@ -1,65 +0,0 @@
<?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>.
*/
#namespace Doctrine::ORM;
/**
* Doctrine_Entity_Exception
*
* @package Doctrine
* @subpackage Entity
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class Doctrine_Entity_Exception extends Doctrine_Exception
{
public static function unknownField($field)
{
return new self("Undefined field: '$field'.");
}
public static function invalidValueForOneToManyReference()
{
return new self("Invalid value. The value of a reference in a OneToMany "
. "association must be a Collection.");
}
public static function invalidValueForOneToOneReference()
{
return new self("Invalid value. The value of a reference in a OneToOne "
. "association must be an Entity.");
}
public static function invalidValueForManyToManyReference()
{
return new self("Invalid value. The value of a reference in a ManyToMany "
. "association must be a Collection.");
}
public static function invalidField($field)
{
return new self("Invalid field: '$field'.");
}
}

View File

@ -350,7 +350,7 @@ class Doctrine_EntityManager
public function setFlushMode($flushMode)
{
if ( ! $this->_isFlushMode($flushMode)) {
throw Doctrine_EntityManager_Exception::invalidFlushMode();
throw Doctrine_ORM_Exceptions_EntityManagerException::invalidFlushMode();
}
$this->_flushMode = $flushMode;
}

View File

@ -1,60 +0,0 @@
<?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>.
*/
#namespace Doctrine::ORM::Exceptions;
/**
* Doctrine_EntityManager_Exception
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class Doctrine_EntityManager_Exception extends Doctrine_Exception
{
public static function invalidFlushMode()
{
return new self("Invalid flush mode.");
}
public static function noEntityManagerAvailable()
{
return new self("No EntityManager available.");
}
public static function entityAlreadyBound($entityName)
{
return new self("The entity '$entityName' is already bound.");
}
public static function noManagerWithName($emName)
{
return new self("EntityManager named '$emName' not found.");
}
public static function unknownAttribute($name)
{
return new self("Unknown EntityManager attribute '$name'.");
}
}

View File

@ -96,7 +96,7 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
/**
* @test
* @expectedException Doctrine_Entity_Exception
* @expectedException Doctrine_ORM_Exceptions_EntityException
*/
public function shouldNotBeAbleToSetNonExistantField()
{
@ -105,7 +105,7 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
/**
* @test
* @expectedException Doctrine_Entity_Exception
* @expectedException Doctrine_ORM_Exceptions_EntityException
*/
public function shouldNotBeAbleToSetNonExistantFieldWithOffset()
{

View File

@ -14,7 +14,7 @@ class Orm_EntityManagerTest extends Doctrine_OrmTestCase
try {
$this->_em->setFlushMode('foobar');
$this->fail("Setting invalid flushmode did not trigger exception.");
} catch (Doctrine_EntityManager_Exception $expected) {}
} catch (Doctrine_ORM_Exceptions_EntityManagerException $expected) {}
$this->_em->setFlushMode($prev);
}
}