From cb464d40616998ac48a9324dc4f4aa1aa84c71ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Felix=20=C5=A0ulc?= Date: Fri, 15 Dec 2023 16:32:45 +0100 Subject: [PATCH] OpenApiPlugin: drop definition helper from contributte/di --- src/OpenApi/DI/OpenApiPlugin.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/OpenApi/DI/OpenApiPlugin.php b/src/OpenApi/DI/OpenApiPlugin.php index 35fad10..0ce4019 100644 --- a/src/OpenApi/DI/OpenApiPlugin.php +++ b/src/OpenApi/DI/OpenApiPlugin.php @@ -12,9 +12,7 @@ use Apitte\OpenApi\SchemaDefinition\JsonDefinition; use Apitte\OpenApi\SchemaDefinition\NeonDefinition; use Apitte\OpenApi\SchemaDefinition\YamlDefinition; -use Contributte\DI\Helper\ExtensionDefinitionsHelper; use Contributte\OpenApi\Tracy\SwaggerPanel; -use Nette\DI\Definitions\Definition; use Nette\DI\Definitions\Statement; use Nette\PhpGenerator\ClassType; use Nette\Schema\Expect; @@ -40,7 +38,6 @@ public function loadPluginConfiguration(): void $builder = $this->getContainerBuilder(); $global = $this->compiler->getExtension()->getConfig(); $config = $this->config; - $definitionHelper = new ExtensionDefinitionsHelper($this->compiler->getExtension()->getCompiler()); $builder->addDefinition($this->prefix('entityAdapter')) ->setFactory(EntityAdapter::class); @@ -73,14 +70,11 @@ public function loadPluginConfiguration(): void $schemaBuilder->addSetup('addDefinition', [new ArrayDefinition($config->definition)]); } else { foreach ($config->definitions as $definitionName => $definitionConfig) { - $definitionPrefix = $this->prefix('definition.' . $definitionName); - $definition = $definitionHelper->getDefinitionFromConfig($definitionConfig, $definitionPrefix); + $definitionDef = $builder->addDefinition($this->prefix('definition.' . $definitionName)) + ->setFactory($definitionConfig) + ->setAutowired(false); - if ($definition instanceof Definition) { - $definition->setAutowired(false); - } - - $schemaBuilder->addSetup('addDefinition', [$definition]); + $schemaBuilder->addSetup('addDefinition', [$definitionDef]); } } @@ -125,7 +119,7 @@ public function afterPluginCompile(ClassType $class): void protected function getConfigSchema(): Schema { return Expect::structure([ - 'definitions' => Expect::arrayOf(Expect::type('string|array|' . Statement::class)), + 'definitions' => Expect::arrayOf(Expect::anyOf(Expect::string(), Expect::type(Statement::class))), 'definition' => Expect::array(), 'files' => Expect::arrayOf('string'), 'swaggerUi' => Expect::structure([