1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\ORM; |
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Cache\Cache as CacheDriver; |
8
|
|
|
use Exception; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Base exception class for all ORM exceptions. |
12
|
|
|
* |
13
|
|
|
* @author Roman Borschel <[email protected]> |
14
|
|
|
* @since 2.0 |
15
|
|
|
*/ |
16
|
|
|
class ORMException extends Exception |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* |
20
|
|
|
* @param string $class |
21
|
|
|
* @param string $association |
22
|
|
|
* @param string $given |
23
|
|
|
* @param string $expected |
24
|
|
|
* |
25
|
|
|
* @return \Doctrine\ORM\ORMInvalidArgumentException |
26
|
|
|
*/ |
27
|
|
|
public static function unexpectedAssociationValue($class, $association, $given, $expected) |
28
|
|
|
{ |
29
|
|
|
return new self(sprintf('Found entity of type %s on association %s#%s, but expecting %s', $given, $class, $association, $expected)); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return ORMException |
34
|
|
|
*/ |
35
|
|
|
public static function invalidResultCacheDriver() |
36
|
|
|
{ |
37
|
|
|
return new self("Invalid result cache driver; it must implement Doctrine\\Common\\Cache\\Cache."); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return ORMException |
42
|
|
|
*/ |
43
|
|
|
public static function notSupported() |
44
|
|
|
{ |
45
|
|
|
return new self("This behaviour is (currently) not supported by Doctrine 2"); |
46
|
|
|
} |
47
|
2 |
|
|
48
|
|
|
/** |
49
|
2 |
|
* @return ORMException |
50
|
|
|
*/ |
51
|
|
|
public static function queryCacheNotConfigured() |
52
|
|
|
{ |
53
|
|
|
return new self('Query Cache is not configured.'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return ORMException |
58
|
|
|
*/ |
59
|
|
|
public static function metadataCacheNotConfigured() |
60
|
|
|
{ |
61
|
|
|
return new self('Class Metadata Cache is not configured.'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param \Doctrine\Common\Cache\Cache $cache |
66
|
|
|
* |
67
|
|
|
* @return ORMException |
68
|
|
|
*/ |
69
|
|
|
public static function queryCacheUsesNonPersistentCache(CacheDriver $cache) |
70
|
|
|
{ |
71
|
|
|
return new self('Query Cache uses a non-persistent cache driver, ' . get_class($cache) . '.'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param \Doctrine\Common\Cache\Cache $cache |
76
|
|
|
* |
77
|
|
|
* @return ORMException |
78
|
|
|
*/ |
79
|
|
|
public static function metadataCacheUsesNonPersistentCache(CacheDriver $cache) |
80
|
|
|
{ |
81
|
|
|
return new self('Metadata Cache uses a non-persistent cache driver, ' . get_class($cache) . '.'); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|