You are here

function _mongodb_field_storage_value in MongoDB 7

Setting the type of field value.

Parameters

string $type: Type of field.

string $value: Vaule of field.

Return value

string Returns the value.

2 calls to _mongodb_field_storage_value()
mongodb_field_storage_field_storage_write in mongodb_field_storage/mongodb_field_storage.module
Implements hook_field_storage_write().
_mongodb_field_storage_query_value in mongodb_field_storage/mongodb_field_storage.module
Build a MongoDB query selector based on EntityQuery syntax.

File

mongodb_field_storage/mongodb_field_storage.module, line 236
Implementation of the field storage API for MongoDB.

Code

function _mongodb_field_storage_value($type, $value) {
  switch ($type) {
    case 'int':
    case 'serial':
      return is_array($value) ? array_map('intval', $value) : intval($value);
    case 'float':
      return is_array($value) ? array_map('floatval', $value) : floatval($value);
    default:
      return $value;
  }
}