From d495a33ab31f3e518148905cd624cd3d41b77fb8 Mon Sep 17 00:00:00 2001 From: romanb Date: Fri, 12 Sep 2008 09:37:22 +0000 Subject: [PATCH] --- .../ORM/Exceptions/EntityException.php | 65 +++++++++++++++++++ .../ORM/Exceptions/EntityManagerException.php | 60 +++++++++++++++++ lib/Doctrine/ORM/Exceptions/ORMException.php | 57 ++++++++++++++++ 3 files changed, 182 insertions(+) create mode 100644 lib/Doctrine/ORM/Exceptions/EntityException.php create mode 100644 lib/Doctrine/ORM/Exceptions/EntityManagerException.php create mode 100644 lib/Doctrine/ORM/Exceptions/ORMException.php diff --git a/lib/Doctrine/ORM/Exceptions/EntityException.php b/lib/Doctrine/ORM/Exceptions/EntityException.php new file mode 100644 index 000000000..19617b115 --- /dev/null +++ b/lib/Doctrine/ORM/Exceptions/EntityException.php @@ -0,0 +1,65 @@ +. + */ + +#namespace Doctrine::ORM::Exceptions; + +/** + * Doctrine_Entity_Exception + * + * @package Doctrine + * @subpackage Entity + * @author Konsta Vesterinen + * @author Roman Borschel + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 2.0 + * @version $Revision$ + */ +class Doctrine_ORM_Exceptions_EntityException extends Doctrine_ORM_Exceptions_ORMException +{ + 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'."); + } +} \ No newline at end of file diff --git a/lib/Doctrine/ORM/Exceptions/EntityManagerException.php b/lib/Doctrine/ORM/Exceptions/EntityManagerException.php new file mode 100644 index 000000000..61823ca90 --- /dev/null +++ b/lib/Doctrine/ORM/Exceptions/EntityManagerException.php @@ -0,0 +1,60 @@ +. + */ + +#namespace Doctrine::ORM::Exceptions; + +/** + * Doctrine_EntityManager_Exception + * + * @author Konsta Vesterinen + * @author Roman Borschel + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 2.0 + * @version $Revision$ + */ +class Doctrine_ORM_Exceptions_EntityManagerException extends Doctrine_ORM_Exceptions_ORMException +{ + 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'."); + } +} \ No newline at end of file diff --git a/lib/Doctrine/ORM/Exceptions/ORMException.php b/lib/Doctrine/ORM/Exceptions/ORMException.php new file mode 100644 index 000000000..c90c733fd --- /dev/null +++ b/lib/Doctrine/ORM/Exceptions/ORMException.php @@ -0,0 +1,57 @@ +. + */ + +#namespace Doctrine::ORM::Exceptions; + +/** + * Doctrine_Exception + * + * @package Doctrine + * @subpackage Exception + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.phpdoctrine.org + * @since 1.0 + * @version $Revision: 4776 $ + * @author Konsta Vesterinen + * @author Roman Borschel + * @todo Rename to DoctrineException + */ +class Doctrine_ORM_Exceptions_ORMException extends Exception +{ + private $_innerException; + + public function __construct($message = "", Exception $innerException = null) + { + parent::__construct($message); + $this->_innerException = $innerException; + } + + public function getInnerException() + { + return $this->_innerException; + } + + public static function notYetImplemented($method, $class) + { + return new self("The method '$method' is not implemented in the class '$class'."); + } + +}