protected function askForHosts($host) { $data = $host->askKnownHosts(); $added = 0; if ($data['hosts']) { foreach ($data['hosts'] as $host_data) { $host = LernmarktplatzHost::findByUrl($host_data['url']); if (!$host) { $host = new LernmarktplatzHost(); $host['url'] = $host_data['url']; $host->fetchPublicKey(); if ($host['public_key']) { $added++; $host->store(); } } else { $host->fetchPublicKey(); } } } return $added; }