userDao = $userDao; } public function findByTypeAndKey($type, $primaryKey) { $query = $this->fpdo ->from($this->tableName) ->where('type', $type) ->where('primaryKey', $primaryKey) ->orderBy('time DESC'); return $this->arrayToEntities(iterator_to_array($query)); } public function afterLoad(Entity $snapshot) { $snapshot->setLazyLoader( Snapshot::LAZY_LOADER_USER, function (Snapshot $snapshot) { return $this->getUser($snapshot); }); } private function getUser(Snapshot $snapshot) { $userId = $snapshot->getUserId(); return $this->userDao->findById($userId); } }