Skip to content

Commit

Permalink
SearchExtension: adds service if class exists but is not autowired
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 14, 2024
1 parent ea318fc commit 73b0cc7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DI/Extensions/SearchExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function beforeCompile(): void
$builder = $this->getContainerBuilder();

foreach ($this->classes as $class => $foo) {
if ($builder->findByType($class)) {
if ($builder->findAutowired($class)) {
unset($this->classes[$class]);
}
}
Expand Down
29 changes: 29 additions & 0 deletions tests/SearchExtension/autowiring.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

use Tester\Assert;

require __DIR__ . '/bootstrap.php';


$services = check('
services:
- ClassOk1
-
create: ClassOk2
autowired: false
search:
in: fixtures
files:
- Ok1.php
- Ok2.php
tags:
- search
');

Assert::same([
'ClassOk1' => [],
'ClassOk2' => ['search' => true],
], $services);

0 comments on commit 73b0cc7

Please sign in to comment.