2009-10-28 10:31:47 +00:00
|
|
|
<?php
|
2010-04-26 13:02:30 +02:00
|
|
|
/*
|
|
|
|
* 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
|
2012-05-26 14:37:00 +02:00
|
|
|
* and is licensed under the MIT license. For more information, see
|
2010-04-26 13:02:30 +02:00
|
|
|
* <http://www.doctrine-project.org>.
|
|
|
|
*/
|
2009-10-28 10:31:47 +00:00
|
|
|
|
|
|
|
namespace Doctrine\ORM;
|
|
|
|
|
2010-05-10 23:51:56 +02:00
|
|
|
use Exception;
|
|
|
|
|
2009-12-18 13:20:22 +00:00
|
|
|
/**
|
|
|
|
* Base exception class for all ORM exceptions.
|
2010-02-24 02:25:09 +00:00
|
|
|
*
|
2009-12-18 13:20:22 +00:00
|
|
|
* @author Roman Borschel <roman@code-factory.org>
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
2010-05-10 23:51:56 +02:00
|
|
|
class ORMException extends Exception
|
2009-10-28 10:31:47 +00:00
|
|
|
{
|
2010-04-10 17:35:18 +02:00
|
|
|
public static function missingMappingDriverImpl()
|
|
|
|
{
|
|
|
|
return new self("It's a requirement to specify a Metadata Driver and pass it ".
|
2012-07-08 14:58:06 +02:00
|
|
|
"to Doctrine\\ORM\\Configuration::setMetadataDriverImpl().");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function namedQueryNotFound($queryName)
|
|
|
|
{
|
|
|
|
return new self('Could not find a named query by the name "' . $queryName . '"');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function namedNativeQueryNotFound($nativeQueryName)
|
|
|
|
{
|
|
|
|
return new self('Could not find a named native query by the name "' . $nativeQueryName . '"');
|
2010-04-10 17:35:18 +02:00
|
|
|
}
|
2011-09-29 09:31:06 +02:00
|
|
|
|
2011-06-05 12:54:29 +02:00
|
|
|
public static function entityMissingForeignAssignedId($entity, $relatedEntity)
|
|
|
|
{
|
|
|
|
return new self(
|
2011-06-15 17:15:46 -04:00
|
|
|
"Entity of type " . get_class($entity) . " has identity through a foreign entity " . get_class($relatedEntity) . ", " .
|
2011-07-26 10:59:21 +03:00
|
|
|
"however this entity has no identity itself. You have to call EntityManager#persist() on the related entity " .
|
2011-07-26 11:03:23 +03:00
|
|
|
"and make sure that an identifier was generated before trying to persist '" . get_class($entity) . "'. In case " .
|
2011-06-05 12:54:29 +02:00
|
|
|
"of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SERIAL) this means you have to call " .
|
|
|
|
"EntityManager#flush() between both persist operations."
|
|
|
|
);
|
|
|
|
}
|
2010-04-10 17:35:18 +02:00
|
|
|
|
2011-09-29 09:31:06 +02:00
|
|
|
public static function entityMissingAssignedIdForField($entity, $field)
|
|
|
|
{
|
|
|
|
return new self("Entity of type " . get_class($entity) . " is missing an assigned ID for field '" . $field . "'. " .
|
|
|
|
"The identifier generation strategy for this entity requires the ID field to be populated before ".
|
|
|
|
"EntityManager#persist() is called. If you want automatically generated identifiers instead " .
|
2011-06-05 12:54:29 +02:00
|
|
|
"you need to adjust the metadata mapping accordingly."
|
|
|
|
);
|
2009-10-28 10:31:47 +00:00
|
|
|
}
|
2012-07-08 14:58:06 +02:00
|
|
|
|
2009-10-28 15:32:55 +00:00
|
|
|
public static function unrecognizedField($field)
|
|
|
|
{
|
|
|
|
return new self("Unrecognized field: $field");
|
|
|
|
}
|
2010-02-24 02:25:09 +00:00
|
|
|
|
2011-11-21 15:04:14 +01:00
|
|
|
/**
|
|
|
|
* @param string $className
|
|
|
|
* @param string $field
|
|
|
|
*/
|
|
|
|
public static function invalidOrientation($className, $field)
|
|
|
|
{
|
|
|
|
return new self("Invalid order by orientation specified for " . $className . "#" . $field);
|
|
|
|
}
|
|
|
|
|
2009-12-18 13:20:22 +00:00
|
|
|
public static function invalidFlushMode($mode)
|
|
|
|
{
|
|
|
|
return new self("'$mode' is an invalid flush mode.");
|
|
|
|
}
|
2010-02-24 02:25:09 +00:00
|
|
|
|
2009-12-18 13:20:22 +00:00
|
|
|
public static function entityManagerClosed()
|
|
|
|
{
|
|
|
|
return new self("The EntityManager is closed.");
|
|
|
|
}
|
2010-02-24 02:25:09 +00:00
|
|
|
|
2010-01-29 21:36:05 +00:00
|
|
|
public static function invalidHydrationMode($mode)
|
|
|
|
{
|
|
|
|
return new self("'$mode' is an invalid hydration mode.");
|
|
|
|
}
|
2010-02-24 02:25:09 +00:00
|
|
|
|
2010-01-29 21:36:05 +00:00
|
|
|
public static function mismatchedEventManager()
|
|
|
|
{
|
|
|
|
return new self("Cannot use different EventManager instances for EntityManager and Connection.");
|
|
|
|
}
|
2010-02-24 02:25:09 +00:00
|
|
|
|
2010-03-03 01:30:00 +00:00
|
|
|
public static function findByRequiresParameter($methodName)
|
|
|
|
{
|
2010-02-24 02:25:09 +00:00
|
|
|
return new self("You need to pass a parameter to '".$methodName."'");
|
|
|
|
}
|
|
|
|
|
2010-03-03 01:30:00 +00:00
|
|
|
public static function invalidFindByCall($entityName, $fieldName, $method)
|
|
|
|
{
|
2010-02-24 02:25:09 +00:00
|
|
|
return new self(
|
|
|
|
"Entity '".$entityName."' has no field '".$fieldName."'. ".
|
|
|
|
"You can therefore not call '".$method."' on the entities' repository"
|
|
|
|
);
|
|
|
|
}
|
2010-03-03 01:30:00 +00:00
|
|
|
|
2010-09-27 22:13:14 +02:00
|
|
|
public static function invalidFindByInverseAssociation($entityName, $associationFieldName)
|
|
|
|
{
|
|
|
|
return new self(
|
|
|
|
"You cannot search for the association field '".$entityName."#".$associationFieldName."', ".
|
|
|
|
"because it is the inverse side of an association. Find methods only work on owning side associations."
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2010-03-05 16:35:00 +00:00
|
|
|
public static function invalidResultCacheDriver() {
|
2012-07-08 14:58:06 +02:00
|
|
|
return new self("Invalid result cache driver; it must implement Doctrine\\Common\\Cache\\Cache.");
|
2010-03-05 16:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function notSupported() {
|
|
|
|
return new self("This behaviour is (currently) not supported by Doctrine 2");
|
|
|
|
}
|
|
|
|
|
2010-03-03 01:30:00 +00:00
|
|
|
public static function queryCacheNotConfigured()
|
|
|
|
{
|
|
|
|
return new self('Query Cache is not configured.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function metadataCacheNotConfigured()
|
|
|
|
{
|
|
|
|
return new self('Class Metadata Cache is not configured.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function proxyClassesAlwaysRegenerating()
|
|
|
|
{
|
|
|
|
return new self('Proxy Classes are always regenerating.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function unknownEntityNamespace($entityNamespaceAlias)
|
|
|
|
{
|
|
|
|
return new self(
|
|
|
|
"Unknown Entity namespace alias '$entityNamespaceAlias'."
|
|
|
|
);
|
|
|
|
}
|
2011-09-29 09:31:06 +02:00
|
|
|
|
|
|
|
public static function invalidEntityRepository($className)
|
2011-09-08 17:21:06 -03:00
|
|
|
{
|
2012-07-26 15:50:51 -04:00
|
|
|
return new self("Invalid repository class '".$className."'. It must be a Doctrine\Common\Persistence\ObjectRepository.");
|
2011-09-08 14:36:13 -03:00
|
|
|
}
|
2011-12-19 22:56:19 +01:00
|
|
|
|
2011-12-01 21:18:39 +01:00
|
|
|
public static function missingIdentifierField($className, $fieldName)
|
|
|
|
{
|
|
|
|
return new self("The identifier $fieldName is missing for a query of " . $className);
|
|
|
|
}
|
2012-07-05 21:52:40 +02:00
|
|
|
|
|
|
|
public static function overwriteInternalDQLFunctionNotAllowed($functionName)
|
|
|
|
{
|
|
|
|
return new self("It is not allowed to overwrite internal function '$functionName' in the DQL parser through user-defined functions.");
|
|
|
|
}
|
2009-10-28 10:31:47 +00:00
|
|
|
}
|