@@ -22,7 +22,7 @@ class Bucket
22
22
private static $ streamWrapper ;
23
23
private static $ defaultChunkSizeBytes = 261120 ;
24
24
25
- private $ collectionsWrapper ;
25
+ private $ collectionWrapper ;
26
26
private $ databaseName ;
27
27
private $ options ;
28
28
@@ -74,7 +74,7 @@ public function __construct(Manager $manager, $databaseName, array $options = []
74
74
75
75
$ collectionOptions = array_intersect_key ($ options , ['readPreference ' => 1 , 'writeConcern ' => 1 ]);
76
76
77
- $ this ->collectionsWrapper = new GridFSCollectionsWrapper ($ manager , $ databaseName , $ options ['bucketName ' ], $ collectionOptions );
77
+ $ this ->collectionWrapper = new CollectionWrapper ($ manager , $ databaseName , $ options ['bucketName ' ], $ collectionOptions );
78
78
$ this ->registerStreamWrapper ($ manager );
79
79
}
80
80
@@ -89,12 +89,12 @@ public function __construct(Manager $manager, $databaseName, array $options = []
89
89
*/
90
90
public function delete (ObjectId $ id )
91
91
{
92
- $ file = $ this ->collectionsWrapper ->getFilesCollection ()->findOne (['_id ' => $ id ]);
93
- $ this ->collectionsWrapper ->getFilesCollection ()->deleteOne (['_id ' => $ id ]);
94
- $ this ->collectionsWrapper ->getChunksCollection ()->deleteMany (['files_id ' => $ id ]);
92
+ $ file = $ this ->collectionWrapper ->getFilesCollection ()->findOne (['_id ' => $ id ]);
93
+ $ this ->collectionWrapper ->getFilesCollection ()->deleteOne (['_id ' => $ id ]);
94
+ $ this ->collectionWrapper ->getChunksCollection ()->deleteMany (['files_id ' => $ id ]);
95
95
96
96
if ($ file === null ) {
97
- throw FileNotFoundException::byId ($ id , $ this ->collectionsWrapper ->getFilesCollection ()->getNameSpace ());
97
+ throw FileNotFoundException::byId ($ id , $ this ->collectionWrapper ->getFilesCollection ()->getNameSpace ());
98
98
}
99
99
100
100
}
@@ -108,16 +108,16 @@ public function delete(ObjectId $id)
108
108
*/
109
109
public function downloadToStream (ObjectId $ id , $ destination )
110
110
{
111
- $ file = $ this ->collectionsWrapper ->getFilesCollection ()->findOne (
111
+ $ file = $ this ->collectionWrapper ->getFilesCollection ()->findOne (
112
112
['_id ' => $ id ],
113
113
['typeMap ' => ['root ' => 'stdClass ' ]]
114
114
);
115
115
116
116
if ($ file === null ) {
117
- throw FileNotFoundException::byId ($ id , $ this ->collectionsWrapper ->getFilesCollection ()->getNameSpace ());
117
+ throw FileNotFoundException::byId ($ id , $ this ->collectionWrapper ->getFilesCollection ()->getNameSpace ());
118
118
}
119
119
120
- $ gridFsStream = new GridFSDownload ($ this ->collectionsWrapper , $ file );
120
+ $ gridFsStream = new GridFSDownload ($ this ->collectionWrapper , $ file );
121
121
$ gridFsStream ->downloadToStream ($ destination );
122
122
}
123
123
@@ -149,7 +149,7 @@ public function downloadToStreamByName($filename, $destination, array $options =
149
149
{
150
150
$ options += ['revision ' => -1 ];
151
151
$ file = $ this ->findFileRevision ($ filename , $ options ['revision ' ]);
152
- $ gridFsStream = new GridFSDownload ($ this ->collectionsWrapper , $ file );
152
+ $ gridFsStream = new GridFSDownload ($ this ->collectionWrapper , $ file );
153
153
$ gridFsStream ->downloadToStream ($ destination );
154
154
}
155
155
@@ -160,7 +160,7 @@ public function downloadToStreamByName($filename, $destination, array $options =
160
160
161
161
public function drop ()
162
162
{
163
- $ this ->collectionsWrapper ->dropCollections ();
163
+ $ this ->collectionWrapper ->dropCollections ();
164
164
}
165
165
166
166
/**
@@ -173,12 +173,12 @@ public function drop()
173
173
*/
174
174
public function find ($ filter , array $ options = [])
175
175
{
176
- return $ this ->collectionsWrapper ->getFilesCollection ()->find ($ filter , $ options );
176
+ return $ this ->collectionWrapper ->getFilesCollection ()->find ($ filter , $ options );
177
177
}
178
178
179
179
public function getCollectionsWrapper ()
180
180
{
181
- return $ this ->collectionsWrapper ;
181
+ return $ this ->collectionWrapper ;
182
182
}
183
183
184
184
public function getDatabaseName ()
@@ -212,13 +212,13 @@ public function getIdFromStream($stream)
212
212
*/
213
213
public function openDownloadStream (ObjectId $ id )
214
214
{
215
- $ file = $ this ->collectionsWrapper ->getFilesCollection ()->findOne (
215
+ $ file = $ this ->collectionWrapper ->getFilesCollection ()->findOne (
216
216
['_id ' => $ id ],
217
217
['typeMap ' => ['root ' => 'stdClass ' ]]
218
218
);
219
219
220
220
if ($ file === null ) {
221
- throw FileNotFoundException::byId ($ id , $ this ->collectionsWrapper ->getFilesCollection ()->getNameSpace ());
221
+ throw FileNotFoundException::byId ($ id , $ this ->collectionWrapper ->getFilesCollection ()->getNameSpace ());
222
222
}
223
223
224
224
return $ this ->openDownloadStreamByFile ($ file );
@@ -273,7 +273,7 @@ public function openUploadStream($filename, array $options = [])
273
273
$ options += ['chunkSizeBytes ' => $ this ->options ['chunkSizeBytes ' ]];
274
274
275
275
$ streamOptions = [
276
- 'collectionsWrapper ' => $ this ->collectionsWrapper ,
276
+ 'collectionWrapper ' => $ this ->collectionWrapper ,
277
277
'uploadOptions ' => $ options ,
278
278
];
279
279
@@ -291,10 +291,10 @@ public function openUploadStream($filename, array $options = [])
291
291
*/
292
292
public function rename (ObjectId $ id , $ newFilename )
293
293
{
294
- $ filesCollection = $ this ->collectionsWrapper ->getFilesCollection ();
294
+ $ filesCollection = $ this ->collectionWrapper ->getFilesCollection ();
295
295
$ result = $ filesCollection ->updateOne (['_id ' => $ id ], ['$set ' => ['filename ' => $ newFilename ]]);
296
296
if ($ result ->getModifiedCount () == 0 ) {
297
- throw FileNotFoundException::byId ($ id , $ this ->collectionsWrapper ->getFilesCollection ()->getNameSpace ());
297
+ throw FileNotFoundException::byId ($ id , $ this ->collectionWrapper ->getFilesCollection ()->getNameSpace ());
298
298
}
299
299
}
300
300
@@ -314,7 +314,7 @@ public function rename(ObjectId $id, $newFilename)
314
314
public function uploadFromStream ($ filename , $ source , array $ options = [])
315
315
{
316
316
$ options += ['chunkSizeBytes ' => $ this ->options ['chunkSizeBytes ' ]];
317
- $ gridFsStream = new GridFSUpload ($ this ->collectionsWrapper , $ filename , $ options );
317
+ $ gridFsStream = new GridFSUpload ($ this ->collectionWrapper , $ filename , $ options );
318
318
319
319
return $ gridFsStream ->uploadFromStream ($ source );
320
320
}
@@ -329,7 +329,7 @@ private function findFileRevision($filename, $revision)
329
329
$ sortOrder = 1 ;
330
330
}
331
331
332
- $ filesCollection = $ this ->collectionsWrapper ->getFilesCollection ();
332
+ $ filesCollection = $ this ->collectionWrapper ->getFilesCollection ();
333
333
$ file = $ filesCollection ->findOne (
334
334
['filename ' => $ filename ],
335
335
[
@@ -349,7 +349,7 @@ private function findFileRevision($filename, $revision)
349
349
private function openDownloadStreamByFile ($ file )
350
350
{
351
351
$ options = [
352
- 'collectionsWrapper ' => $ this ->collectionsWrapper ,
352
+ 'collectionWrapper ' => $ this ->collectionWrapper ,
353
353
'file ' => $ file ,
354
354
];
355
355
0 commit comments