public function getLastModified(array $users, $imageIdentifier = null)
{
try {
// Query on the user
$query = ['user' => ['$in' => $users]];
if ($imageIdentifier) {
// We want information about a single image. Add the identifier to the query
$query['imageIdentifier'] = $imageIdentifier;
}
// Find a document
$data = $this->getImageCollection()->findOne($query, ['sort' => ['updated' => -1], 'projection' => ['updated' => true]]);
} catch (MongoException $e) {
throw new DatabaseException('Unable to fetch image data', 500, $e);
}
if ($data === null && $imageIdentifier) {
throw new DatabaseException('Image not found', 404);
} else {
if ($data === null) {
$data = ['updated' => time()];
}
}
return new DateTime('@' . $data['updated'], new DateTimeZone('UTC'));
}