clauseFactory = $clauseFactory; $this->connectiveFactory = $connectiveFactory; $this->fieldEntityAttributesPool = $fieldEntityAttributesPool; } /** * Get a clause from an AST * * @param string $fieldName * @param array $arguments * @return array */ public function getClausesFromAst(string $fieldName, array $arguments) : array { $attributes = $this->fieldEntityAttributesPool->getEntityAttributesForEntityFromField($fieldName); $conditions = []; foreach ($arguments as $argumentName => $argument) { if (in_array($argumentName, $attributes)) { foreach ($argument as $clauseType => $clause) { if (is_array($clause)) { $value = []; foreach ($clause as $item) { $value[] = $item; } } else { $value = $clause; } $conditions[] = $this->clauseFactory->create( $argumentName, $clauseType, $value ); } } else { $conditions[] = $this->connectiveFactory->create( $this->getClausesFromAst($fieldName, $argument), $argumentName ); } } return $conditions; } }