Skip to content

Commit

Permalink
ImageStorageExtension add baseDir parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
MartkCz committed Aug 15, 2021
1 parent a38b09e commit cffe15f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Bridge/Nette/DI/ImageStorageExtension.php
Expand Up @@ -83,6 +83,8 @@ final class ImageStorageExtension extends CompilerExtension

public function getConfigSchema(): Schema
{
$builder = $this->getContainerBuilder();

return Expect::structure([
'extensions' => Expect::structure([
'doctrine' => Expect::structure([
Expand All @@ -102,6 +104,7 @@ public function getConfigSchema(): Schema
'enabled' => Expect::bool(class_exists(AbstractImagine::class)),
]),
]),
'baseDir' => Expect::string($builder->parameters['wwwDir']),
]);
}

Expand Down Expand Up @@ -186,14 +189,13 @@ public function beforeCompile(): void

private function loadFilesystem(ContainerBuilder $builder): void
{
if (!isset($builder->parameters['wwwDir'])) {
throw new LogicException('Neon parameter %wwwDir% must be configured');
}
/** @var stdClass $config */
$config = $this->getConfig();

$builder->addDefinition($this->prefix('filesystem'))
->setType(FilesystemInterface::class)
->setFactory(LocalFilesystem::class, [
$builder->parameters['wwwDir'],
$config->baseDir,
]);
}

Expand Down

0 comments on commit cffe15f

Please sign in to comment.