$nsi = str_replace('$nwplatform', $this->nwplatform, $nsi);
$nsi = str_replace('$nsisdir', '/usr/local/share/nsis', $nsi);
$nsi = str_replace('$output', $this->getPathBase('exe'), $nsi);
- $nsi = str_replace('$favicon', $this->theme->favicon(), $nsi);
+ $nsi = str_replace('$favicon', $this->theme->getFaviconPath(), $nsi);
$this->nsi = $nsi;
}
}
foreach (['png', 'ico', 'icns'] as $format) {
- $this->copy($this->theme->favicon($format), $this->vdir . '/icon.' . $format);
+ $this->copy($this->theme->getFaviconPath($format), $this->vdir . '/icon.' . $format);
}
file_put_contents($this->vdir . '/package.json', json_encode($data));
$this->log('Got index vars 3');
$favicon = '';
- if ($this->theme->hasFavicon()) {
- $pngFile = $this->theme->favicon('png');
- $this->vdir->copy($this->theme->favicon('ico'), 'data/favicon.ico');
+ if ($this->theme->hasFaviconFile()) {
+ $pngFile = $this->theme->getFaviconPath('png');
+ $this->vdir->copy($this->theme->getFaviconPath('ico'), 'data/favicon.ico');
$this->vdir->copy($pngFile, 'data/favicon.png');
$this->vdir->copy($pngFile, 'data/apple-touch-icon.png');
/**
* @throws \Exception
*/
- public function favicon($format = 'ico')
+ public function getFaviconPath($format = 'ico')
{
$supported = ['ico', 'png', 'icns'];
if (!in_array($format, $supported)) {
throw new \Exception('Unsupported format ' . $format);
}
- if (!$this->hasFavicon()) {
+ if (!$this->hasFaviconFile()) {
return resource_path('fluidbookpublication/favicon/fluidbook.' . $format);
}
$pngSource = $this->getFirstMediaInField('favicon')->getPath();
}
- public function hasFavicon()
+ /**
+ * @return bool
+ */
+ public function hasFaviconFile()
{
- $media=$this->getFirstMediaInField('favicon');
- return !is_null($media) && !($this->getSettings()->get('favicon', '') == '') && file_exists($media->getPath());
+ try {
+ $media = $this->getFirstMediaInField('favicon');
+ return !is_null($media) && !($this->getSettings()->get('favicon', '') == '') && file_exists($media->getPath());
+ } catch (\Exception $e) {
+ return false;
+ }
}
/**