function it_throws_an_exception_if_settings_schema_does_not_exist(ThemeInterface $theme) { $theme->getTitle()->willReturn('Candy shop'); $theme->getName()->willReturn('candy/shop'); $theme->getPath()->willReturn($this->vfsStream->url()); $this->shouldThrow(new \InvalidArgumentException(sprintf('Could not find settings schema of theme "Candy shop" (candy/shop) in file "%s"', $this->vfsStream->url() . '/Settings.php')))->during('getSchema', [$theme]); }
/** * @param ThemeInterface $theme * @param int $screenshotNumber * * @return string */ private function getScreenshotPath(ThemeInterface $theme, $screenshotNumber) { $screenshots = $theme->getScreenshots(); if (!isset($screenshots[$screenshotNumber])) { throw new NotFoundHttpException(sprintf('Theme "%s" does not have screenshot #%d', $theme->getTitle(), $screenshotNumber)); } $screenshotRelativePath = $screenshots[$screenshotNumber]; return rtrim($theme->getPath(), \DIRECTORY_SEPARATOR) . \DIRECTORY_SEPARATOR . $screenshotRelativePath; }
/** * {@inheritdoc} */ public function getSchema(ThemeInterface $theme) { $schemaPath = sprintf('%s/Settings.php', $theme->getPath()); if (!file_exists($schemaPath)) { throw new \InvalidArgumentException(sprintf('Could not find settings schema of theme "%s" (%s) in file "%s"', $theme->getTitle(), $theme->getName(), $schemaPath)); } $schema = (require $schemaPath); if (!$schema instanceof SchemaInterface) { throw new \InvalidArgumentException(sprintf('File "%s" must return an instance of "%s"', $schemaPath, SchemaInterface::class)); } return $schema; }