1 | <?php |
||
5 | class Definition |
||
6 | { |
||
7 | const DEFAULT_COLLECTION_CLASS = '\Sokil\Mongo\Collection'; |
||
8 | const DEFAULT_GRIDFS_CLASS = '\Sokil\Mongo\GridFS'; |
||
9 | |||
10 | const LOCK_NONE = 'NONE'; |
||
11 | const LOCK_OPTIMISTIC = 'OPTIMISTIC'; |
||
12 | const LOCK_PESSIMISTIC = 'PESSIMISTIC'; |
||
13 | |||
14 | /** |
||
15 | * Fully qualified collection class |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | private $class; |
||
20 | |||
21 | /** |
||
22 | * |
||
23 | * @var bool is collection GridFs |
||
24 | */ |
||
25 | private $gridfs; |
||
26 | |||
27 | /** |
||
28 | * Fully qualified document class or callable that returns classname |
||
29 | * @var string|callable |
||
30 | */ |
||
31 | private $documentClass = '\Sokil\Mongo\Document'; |
||
32 | |||
33 | /** |
||
34 | * @var bool Using document versioning |
||
35 | */ |
||
36 | private $versioning = false; |
||
37 | |||
38 | /** |
||
39 | * @var array List of relations |
||
40 | */ |
||
41 | private $relations = array(); |
||
42 | |||
43 | /** |
||
44 | * @var array Index definition |
||
45 | */ |
||
46 | private $index = array(); |
||
47 | |||
48 | /** |
||
49 | * Fully qualified expression class for custom query builder |
||
50 | */ |
||
51 | private $expressionClass = '\Sokil\Mongo\Expression'; |
||
52 | |||
53 | /** |
||
54 | * List of behaviors, attached to every document |
||
55 | */ |
||
56 | private $behaviors = array(); |
||
57 | |||
58 | /** |
||
59 | * Number of documents to return in each batch of response |
||
60 | */ |
||
61 | private $batchSize; |
||
62 | |||
63 | /** |
||
64 | * Instructs the driver to stop waiting for a response and throw a |
||
65 | * MongoCursorTimeoutException after a set time |
||
66 | * A timeout can be set at any time and will affect subsequent queries on |
||
67 | * the cursor, including fetching more results from the database. |
||
68 | * @link http://php.net/manual/en/mongocursor.timeout.php |
||
69 | * @var int time in milliseconds |
||
70 | */ |
||
71 | private $cursorClientTimeout; |
||
72 | |||
73 | /** |
||
74 | * Server-side timeout for a query |
||
75 | * Specifies a cumulative time limit in milliseconds to be allowed |
||
76 | * by the server for processing operations on the cursor. |
||
77 | * @link http://php.net/manual/en/mongocursor.maxtimems.php |
||
78 | * @var int time in milliseconds |
||
79 | */ |
||
80 | private $cursorServerTimeout; |
||
81 | |||
82 | private $regexp; |
||
83 | |||
84 | private $capped; |
||
85 | |||
86 | private $size; |
||
87 | |||
88 | private $max; |
||
89 | |||
90 | private $lock = self::LOCK_NONE; |
||
91 | |||
92 | private $documentPool = true; |
||
93 | |||
94 | private $options = array(); |
||
95 | |||
96 | public function __construct(array $definition = null) |
||
97 | { |
||
98 | if ($definition) { |
||
99 | $this->merge($definition); |
||
100 | } |
||
101 | } |
||
102 | |||
103 | public function __get($name) |
||
104 | { |
||
105 | return $this->getOption($name); |
||
106 | } |
||
107 | |||
108 | public function __set($name, $value) |
||
112 | |||
113 | public function merge(array $definition) |
||
121 | |||
122 | public function setOption($name, $value) |
||
123 | { |
||
136 | |||
137 | public function getOption($name) |
||
145 | |||
146 | public function setClass($class) |
||
151 | |||
152 | public function getClass() |
||
162 | |||
163 | /** |
||
164 | * Get fully qualified class name of expression for current collection instance |
||
165 | * |
||
166 | * @return string |
||
167 | */ |
||
168 | public function getExpressionClass() |
||
172 | |||
173 | public function getMongoCollectionOptions() |
||
185 | |||
186 | public function getOptions() |
||
208 | } |
||
209 |