Thread = ClassRegistry::init('Thread'); $thread = $this->Thread->find('first', [ 'recursive' => -1, 'conditions' => ['id' => $data['Post']['thread_id']], ]); $data['Thread'] = !empty($thread) ? $thread['Thread'] : []; if (!empty($thread) && !empty($thread['Thread']['event_id'])) { $this->Event = ClassRegistry::init('Event'); $event = $this->Event->find('first', [ 'recursive' => -1, 'conditions' => ['id' => $thread['Thread']['event_id']], ]); $event = $this->convertData($event); $data['Event'] = $event['Event']; } return $data; } }