protected function Cache::getBinDataCreator in MongoDB 7
Return the proper MongoBinData constructor with its type argument.
The signature of \MongoBinData::__construct() changed in 1.2.11 to require $type and default to BYTE_ARRAY, then again in 1.5.0 to default to GENERIC.
Return value
\Closure A closure wrapping the constructor with its expected $type.
1 call to Cache::getBinDataCreator()
- Cache::__construct in mongodb_cache/
mongodb_cache_plugin.php - Constructor.
File
- mongodb_cache/
mongodb_cache_plugin.php, line 146
Class
- Cache
- MongoDB cache implementation.
Namespace
Drupal\mongodb_cacheCode
protected function getBinDataCreator() {
$mongoVersion = phpversion('mongo');
if (version_compare($mongoVersion, '1.2.11') < 0) {
$result = function ($data) {
return new \MongoBinData($data);
};
}
else {
$type = version_compare($mongoVersion, '1.5.0') < 0 ? \MongoBinData::BYTE_ARRAY : \MongoBinData::GENERIC;
$result = function ($data) use ($type) {
return new \MongoBinData($data, $type);
};
}
return $result;
}