/** * Detect the active module and setup our * environment with it. */ public function handle() { /** * In order to detect we MUST have a route * and we MUST have a namespace in the * streams::addon action parameter. * * @var Route $route */ $route = $this->request->route(); /* @var Module $module */ if ($route && ($module = $this->modules->get(array_get($route->getAction(), 'streams::addon')))) { $module->setActive(true); } if (!$module && $this->request->segment(1) == 'admin' && ($module = $this->modules->findBySlug($this->request->segment(2)))) { $module->setActive(true); } if (!$module) { return; } $this->container->make('view')->addNamespace('module', $module->getPath('resources/views')); $this->container->make('translator')->addNamespace('module', $module->getPath('resources/lang')); $this->asset->addPath('module', $module->getPath('resources')); $this->image->addPath('module', $module->getPath('resources')); }
/** * Return the response headers. * * @param Image $image * @param int $quality * @return Response */ public function generate(Image $image, $quality = 100) { $response = parent::make($image->getImage()); $response->headers->set('Content-Disposition', 'inline'); $response->headers->remove('Content-Length'); $response = $response->setContent($image->encode(null, $quality)); return $response->sendHeaders(); }
/** * Run a macro. * * @param $macro * @param Image $image * @return Image * @throws \Exception */ public function run($macro, Image $image) { if (!($process = array_get($this->getMacros(), $macro))) { return $image; } if (is_array($process)) { foreach ($process as $method => $arguments) { $image->addAlteration($method, $arguments); } } if ($process instanceof \Closure) { $this->container->call($process, compact('image', 'macro')); } return $image; }
/** * Handle the command. */ public function handle(Image $image, Container $container, Application $application) { $image->addPath('public', base_path('public')); $image->addPath('node', base_path('node_modules')); $image->addPath('asset', $application->getAssetsPath()); $image->addPath('streams', $container->make('streams.path') . '/resources'); $image->addPath('bower', $container->make('path.base') . '/bin/bower_components'); }
/** * Detect the active theme and set up * our environment with it. */ public function handle() { $admin = $this->themes->get($this->config->get('streams::themes.admin')); $standard = $this->themes->get($this->config->get('streams::themes.standard')); if ($admin) { $admin->setActive(true); } if ($standard) { $standard->setActive(true); } if ($admin && in_array($this->request->segment(1), ['installer', 'admin'])) { $admin->setCurrent(true); } elseif ($standard) { $standard->setCurrent(true); } if ($theme = $this->themes->current()) { $this->view->addNamespace('theme', $theme->getPath('resources/views')); $this->translator->addNamespace('theme', $theme->getPath('resources/lang')); $this->asset->addPath('theme', $theme->getPath('resources')); $this->image->addPath('theme', $theme->getPath('resources')); } }
/** * Return the output path for an image. * * @param $path * @return string */ public function outputPath(Image $image) { $path = $image->getImage(); if ($path instanceof FileInterface) { $path = $path->path(); } /** * If the path is already public * then just use it as it is. */ if (str_contains($path, public_path())) { return str_replace(public_path(), '', $path); } /** * If the path is a file or file path then * put it in /app/{$application}/files/disk/folder/filename.ext */ if (is_string($path) && str_is('*://*', $path)) { $application = $this->application->getReference(); list($disk, $folder, $filename) = explode('/', str_replace('://', '/', $path)); if ($rename = $image->getFilename()) { $filename = $rename; if (strpos($filename, DIRECTORY_SEPARATOR)) { $directory = null; } } return "/app/{$application}/files/{$disk}/{$folder}/{$filename}"; } /** * Get the real path relative to our installation. */ $path = str_replace(base_path(), '', $this->realPath($path)); /** * Build out path parts. */ $filename = basename($path); $directory = ltrim(dirname($path), '/\\') . '/'; $application = $this->application->getReference(); if ($image->getAlterations() || $image->getQuality()) { $filename = md5(var_export([$path, $image->getAlterations()], true) . $image->getQuality()) . '.' . $image->getExtension(); } if ($rename = $image->getFilename()) { $directory = null; $filename = ltrim($rename, '/\\'); } return "/app/{$application}/assets/{$directory}{$filename}"; }
/** * Handle the command. * * @param Image $image * @return $this */ public function handle(Image $image) { return $image->make($this->image)->setOutput('url'); }
/** * Handle the command. * * @param Image $image * @return Image */ public function handle(Image $image) { return $image->make($this->file->location())->setOutput('image'); }