mcpError('validation', "entityType must be one of: machine, composant, piece, product. Got '{$entityType}'."); } $rows = $this->em->createQueryBuilder() ->select( 'cfv.id', 'cfv.value', 'cf.id AS customFieldId', 'cf.name AS customFieldName', 'cf.type AS customFieldType', 'cf.required AS customFieldRequired', 'cfv.createdAt', 'cfv.updatedAt', ) ->from(CustomFieldValue::class, 'cfv') ->join('cfv.customField', 'cf') ->where("IDENTITY(cfv.{$entityType}) = :entityId") ->setParameter('entityId', $entityId) ->orderBy('cf.name', 'ASC') ->getQuery() ->getArrayResult() ; return $this->jsonResponse([ 'entityType' => $entityType, 'entityId' => $entityId, 'values' => $rows, 'total' => count($rows), ]); } }