diff --git a/src/Controller/Component/CRUDComponent.php b/src/Controller/Component/CRUDComponent.php index 5eca579..af8e193 100644 --- a/src/Controller/Component/CRUDComponent.php +++ b/src/Controller/Component/CRUDComponent.php @@ -568,16 +568,16 @@ class CRUDComponent extends Component $query->where($params['conditions']); } $data = $query->first(); + if ($this->metaFieldsSupported()) { + $metaTemplates = $this->getMetaTemplates(); + $data = $this->attachMetaTemplatesIfNeeded($data, $metaTemplates->toArray()); + } if (isset($params['afterFind'])) { $data = $params['afterFind']($data, $params); } if (empty($data)) { throw new NotFoundException(__('Invalid {0}.', $this->ObjectAlias)); } - if ($this->metaFieldsSupported()) { - $metaTemplates = $this->getMetaTemplates(); - $data = $this->attachMetaTemplatesIfNeeded($data, $metaTemplates->toArray()); - } if ($this->request->is(['post', 'put'])) { $patchEntityParams = [ 'associated' => []