Extract is_in_transaction helper from Collection class

parent b356e8ce
This diff is collapsed.
......@@ -110,6 +110,22 @@ function is_first_key_operator($document)
return (isset($firstKey[0]) && $firstKey[0] === '$');
}
/**
* Returns whether we are currently in a transaction.
*
* @internal
* @param array $options Command options
* @return boolean
*/
function is_in_transaction(array $options)
{
if (isset($options['session']) && $options['session'] instanceof \MongoDB\Driver\Session && $options['session']->isInTransaction()) {
return true;
}
return false;
}
/**
* Return whether the aggregation pipeline ends with an $out operator.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment