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
|
|
|
* @param string $field |
20
|
|
|
* |
21
|
|
|
* @return ORMException |
22
|
|
|
*/ |
23
|
|
|
public static function unrecognizedField($field) |
24
|
|
|
{ |
25
|
|
|
return new self("Unrecognized field: $field"); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* |
30
|
|
|
* @param string $class |
31
|
|
|
* @param string $association |
32
|
|
|
* @param string $given |
33
|
|
|
* @param string $expected |
34
|
|
|
* |
35
|
|
|
* @return \Doctrine\ORM\ORMInvalidArgumentException |
36
|
|
|
*/ |
37
|
|
|
public static function unexpectedAssociationValue($class, $association, $given, $expected) |
38
|
|
|
{ |
39
|
|
|
return new self(sprintf('Found entity of type %s on association %s#%s, but expecting %s', $given, $class, $association, $expected)); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return ORMException |
44
|
|
|
*/ |
45
|
|
|
public static function invalidResultCacheDriver() |
46
|
|
|
{ |
47
|
2 |
|
return new self("Invalid result cache driver; it must implement Doctrine\\Common\\Cache\\Cache."); |
48
|
|
|
} |
49
|
2 |
|
|
50
|
|
|
/** |
51
|
|
|
* @return ORMException |
52
|
|
|
*/ |
53
|
|
|
public static function notSupported() |
54
|
|
|
{ |
55
|
|
|
return new self("This behaviour is (currently) not supported by Doctrine 2"); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return ORMException |
60
|
|
|
*/ |
61
|
|
|
public static function queryCacheNotConfigured() |
62
|
|
|
{ |
63
|
|
|
return new self('Query Cache is not configured.'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return ORMException |
68
|
|
|
*/ |
69
|
|
|
public static function metadataCacheNotConfigured() |
70
|
|
|
{ |
71
|
|
|
return new self('Class Metadata Cache is not configured.'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param \Doctrine\Common\Cache\Cache $cache |
76
|
|
|
* |
77
|
|
|
* @return ORMException |
78
|
|
|
*/ |
79
|
|
|
public static function queryCacheUsesNonPersistentCache(CacheDriver $cache) |
80
|
|
|
{ |
81
|
|
|
return new self('Query Cache uses a non-persistent cache driver, ' . get_class($cache) . '.'); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
1 |
|
* @param \Doctrine\Common\Cache\Cache $cache |
86
|
|
|
* |
87
|
1 |
|
* @return ORMException |
88
|
1 |
|
*/ |
89
|
1 |
|
public static function metadataCacheUsesNonPersistentCache(CacheDriver $cache) |
90
|
1 |
|
{ |
91
|
|
|
return new self('Metadata Cache uses a non-persistent cache driver, ' . get_class($cache) . '.'); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|