Skip to content

Commit 9fc0566

Browse files
committed
NoAutowire
1 parent 3a59b5a commit 9fc0566

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Windwalker\DI\Attributes;
6+
7+
#[\Attribute(\Attribute::TARGET_PARAMETER)]
8+
class NoAutowire
9+
{
10+
}

packages/di/src/DependencyResolver.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use UnexpectedValueException;
1919
use Windwalker\DI\Attributes\Lazy;
2020
use Windwalker\DI\Attributes\Factory;
21+
use Windwalker\DI\Attributes\NoAutowire;
2122
use Windwalker\DI\Attributes\Service;
2223
use Windwalker\DI\Definition\DefinitionInterface;
2324
use Windwalker\DI\Definition\ObjectBuilderDefinition;
@@ -334,6 +335,8 @@ public function &resolveParameterDependency(
334335
$autowire = $options->autowire;
335336
$nope = null;
336337

338+
$noAutowire = $param->getAttributes(NoAutowire::class) !== [];
339+
337340
$type = $param->getType();
338341
// $dependencyVarName = $param->getName();
339342

@@ -374,6 +377,10 @@ public function &resolveParameterDependency(
374377
return $args[$dependencyClassName];
375378
}
376379

380+
if ($noAutowire) {
381+
continue;
382+
}
383+
377384
$create = function &() use (
378385
$options,
379386
$param,

0 commit comments

Comments
 (0)