-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMongoGridFSCursorPlus.class.php
54 lines (47 loc) · 1.37 KB
/
MongoGridFSCursorPlus.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Contains the single "unit" data abstraction classes, intended to be used in an OOP framework
*
*/
/**
* Provides tighter integration for lists of mongocollectionplus objects. This is returned by mongocollectionplus instead of a standard cursor if you call findObjects
* @author Micah Stevens <[email protected]>
* @version 1.0 - initial release
*
* @package Core
*/
class MongoGridFSCursorPlus extends MongoGridFSCursor
{
var $site; // site object
var $collectionType;
function __construct($site, $gridFS, $className, $collectionName, $query)
{
$this->site = $site;
$this->collectionType = $className;
parent::__construct( $gridFS, $this->site->db, $collectionName, $query, array());
}
/**
* grabs the array from the parent, and creates an object that matches the passed collection and returns it populated with the data.
*
* @return object instance of the populated collection object
*/
function current()
{
$current = parent::current();
if ($current === null)
{
return null; // nothing is nothing
}
// if it's a temp collection, we need to pass the generated name over.
if ($this->collectionType == 'MongoTempCollection')
{
$object = new $this->collectionType($this->site, $collectionName);
}
else
{
$object = new $this->collectionType($this->site);
}
$object->loadRow($current);
return $object;
}
}