diff --git a/src/QueryObject.php b/src/QueryObject.php index f0e3ddb..f11b144 100644 --- a/src/QueryObject.php +++ b/src/QueryObject.php @@ -679,6 +679,11 @@ public static function doPostFetch(EntityManagerInterface $em, array $rootEntiti $childrenFieldNames = []; // fieldName => childrenFieldNames foreach ($fieldNames as $fieldName) { + if (is_callable($fieldName)) { + $fieldName($em, $rootEntities); + continue; + } + if (!Strings::contains($fieldName, '.')) { // fetch jen pro toto pole $currentFieldNames[] = $fieldName; @@ -916,10 +921,10 @@ final public function postFetch(Iterator $iterator): void /** * Přidá pole do seznamu pro postFetch. - * @param string $fieldName Může být název pole (např. "contact") nebo cesta (např. "commission.contract.client"). + * @param string|callable $fieldName Může být název pole (např. "contact") nebo cesta (např. "commission.contract.client"). * @return $this */ - final public function addPostFetch(string $fieldName): static + final public function addPostFetch(string|callable $fieldName): static { $this->postFetch[] = $fieldName; return $this;