protected static function getImage(UniformResourceLocator $locator, $details, $image) { $image = $details["details.images.{$image}"]; if (!strpos($image, '://')) { $name = $details['name']; $image = "gantry-themes-{$name}://{$image}"; } try { $image = $locator->findResource($image, false); } catch (\Exception $e) { $image = false; } return $image; }
protected static function getImage(UniformResourceLocator $locator, $details, $image) { $image = $details["details.images.{$image}"]; if (!strpos($image, '://')) { $name = $details['name']; // Stream needs to be valid URL. $streamName = 'gantry-themes-' . preg_replace('|[^a-z\\d+.-]|ui', '-', $name); $image = "{$streamName}://{$image}"; } try { $image = $locator->findResource($image, false); } catch (\Exception $e) { $image = false; } return $image; }
/** * @param UniformResourceLocator $locator * @throws \InvalidArgumentException */ protected function check(UniformResourceLocator $locator) { $streams = isset($this->items['streams']['schemes']) ? $this->items['streams']['schemes'] : null; if (!is_array($streams)) { throw new \InvalidArgumentException('Configuration is missing streams.schemes!'); } $diff = array_keys(array_diff_key($this->streams, $streams)); if ($diff) { throw new \InvalidArgumentException(sprintf('Configuration is missing keys %s from streams.schemes!', implode(', ', $diff))); } if (!$locator->findResource('environment://config', true)) { // If environment does not have its own directory, remove it from the lookup. $this->set('streams.schemes.environment.prefixes', ['config' => []]); $this->initializeLocator($locator); } // Create security.yaml if it doesn't exist. $filename = $locator->findResource('config://security.yaml', true, true); $file = YamlFile::instance($filename); if (!$file->exists()) { $file->save(['salt' => Utils::generateRandomString(14)]); $file->free(); } }