public function transformSubConditionToMongoCondition($condition, array &$aliases)
    {
        $elements = array();
        $subElements = array();
        $operator = '$and';
        if (preg_match_all(KeywordableTraitInterface::IS_AND_BOOLEAN, $condition, $elements)) {
            preg_match_all(KeywordableTraitInterface::GET_AND_SUB_BOOLEAN, $condition, $subElements);
        } elseif  (preg_match_all(KeywordableTraitInterface::IS_OR_BOOLEAN, $condition, $elements)) {
            $operator = '$or';
            preg_match_all(KeywordableTraitInterface::GET_OR_SUB_BOOLEAN, $condition, $subElements);
        }
        if (count($elements) > 0) {
            foreach ($elements as $key => $element) {
                $elements[$key] = array_merge($element, $subElements[$key]);
            }
            $result = array();
            foreach ($elements[2] as $key => $element) {
                if (array_key_exists($element, $aliases)) {
                    if ($elements[1][$key] != '') {
                        array_push($result, array('$not' => $aliases[$element]));
                    } else {
                        array_push($result, $aliases[$element]);
                    }
                    unset($aliases[$element]);
                } else {
                    $comparison = ($elements[1][$key] == '') ? '$eq' : '$ne';
                    array_push($result, array('keywords.$id' => array($comparison => new \MongoId($element))));
                }
            }

            return (array($operator => $result));
        }

        return null;
    }
public function transformSubConditionToMongoCondition($condition, array &$aliases)
    {
        $elements = array();
        $subElements = array();
        $operator = '$and';
        if (preg_match_all(KeywordableTraitInterface::IS_AND_BOOLEAN, $condition, $elements)) {
            preg_match_all(KeywordableTraitInterface::GET_AND_SUB_BOOLEAN, $condition, $subElements);
        } elseif  (preg_match_all(KeywordableTraitInterface::IS_OR_BOOLEAN, $condition, $elements)) {
            $operator = '$or';
            preg_match_all(KeywordableTraitInterface::GET_OR_SUB_BOOLEAN, $condition, $subElements);
        }
        if (count($elements) > 0) {
            foreach ($elements as $key => $element) {
                $elements[$key] = array_merge($element, $subElements[$key]);
            }
            $result = array();
            foreach ($elements[2] as $key => $element) {
                if (array_key_exists($element, $aliases)) {
                    if ($elements[1][$key] != '') {
                        array_push($result, array('$not' => $aliases[$element]));
                    } else {
                        array_push($result, $aliases[$element]);
                    }
                    unset($aliases[$element]);
                } else {
                    $comparison = ($elements[1][$key] == '') ? '$eq' : '$ne';
                    array_push($result, array('keywords.$id' => array($comparison => new \MongoId($element))));
                }
            }

            return (array($operator => $result));
        }

        return null;
    }
@param string $condition
@param array  $aliases

@return array|null