Get the path to the public / web directory.
public publicPath ( ) : string | ||
return | string |
/** * {@inheritdoc} */ public function data(ServerRequestInterface $request, Document $document) { $this->assertAdmin($request->getAttribute('actor')); $file = array_get($request->getUploadedFiles(), 'favicon'); $tmpFile = tempnam($this->app->storagePath() . '/tmp', 'favicon'); $file->moveTo($tmpFile); $extension = pathinfo($file->getClientFilename(), PATHINFO_EXTENSION); if ($extension !== 'ico') { $manager = new ImageManager(); $encodedImage = $manager->make($tmpFile)->resize(64, 64, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->encode('png'); file_put_contents($tmpFile, $encodedImage); $extension = 'png'; } $mount = new MountManager(['source' => new Filesystem(new Local(pathinfo($tmpFile, PATHINFO_DIRNAME))), 'target' => new Filesystem(new Local($this->app->publicPath() . '/assets'))]); if (($path = $this->settings->get('favicon_path')) && $mount->has($file = "target://{$path}")) { $mount->delete($file); } $uploadName = 'favicon-' . Str::lower(Str::quickRandom(8)) . '.' . $extension; $mount->move('source://' . pathinfo($tmpFile, PATHINFO_BASENAME), "target://{$uploadName}"); $this->settings->set('favicon_path', $uploadName); return parent::data($request, $document); }
/** * {@inheritdoc} */ protected function delete(ServerRequestInterface $request) { $this->assertAdmin($request->getAttribute('actor')); $path = $this->settings->get('favicon_path'); $this->settings->set('favicon_path', null); $uploadDir = new Filesystem(new Local($this->app->publicPath() . '/assets')); if ($uploadDir->has($path)) { $uploadDir->delete($path); } return new EmptyResponse(204); }
/** * @param Application $app * @return ConfigRepository */ protected function getIlluminateConfig(Application $app) { return new ConfigRepository(['view' => ['paths' => [], 'compiled' => $app->storagePath() . '/views'], 'mail' => ['driver' => 'mail'], 'cache' => ['default' => 'file', 'stores' => ['file' => ['driver' => 'file', 'path' => $app->storagePath() . '/cache']], 'prefix' => 'flarum'], 'filesystems' => ['default' => 'local', 'cloud' => 's3', 'disks' => ['flarum-avatars' => ['driver' => 'local', 'root' => $app->publicPath() . '/assets/avatars']]]]); }
protected function getDestination() { return $this->app->publicPath() . '/assets'; }