/** * Downloads a bookmark favicon. * * @param string $url The bookmark URL. * @param int $id The feed id. */ public function downloadBookmark(Bookmark $bookmark) { $icon = new Icon(); $icon->id_bookmark = $bookmark->id; $icon->data = $this->downloadIcon($this->guessIconURL($bookmark->url)); $icon->save(); }
/** * Imports the favicons into the database and deletes them from filesystem. */ protected function importIcons() { $this->printLine('Importing icons…'); $iconsDir = sprintf('%s/public/icons', getcwd()); foreach ($this->types as $type) { $path = "{$iconsDir}/{$type}/*.ico"; foreach (glob($path) as $file) { $icon = new Icon(); $icon->data = file_get_contents($file); if ($type === 'feed') { $icon->id_feed = str_replace('.ico', '', basename($file)); } else { $icon->id_bookmark = str_replace('.ico', '', basename($file)); } if ($icon->save()) { unlink($file); } } } $this->printLine('Icons imported!'); }