-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SearchExtension: ignores classes that do not have autowired parameters #316
base: master
Are you sure you want to change the base?
Conversation
…od (BC break)" This reverts commit 87662eb.
added Definition::getDescriptor(), Helpers::entityToString()
This would make it hard to reason about why some service is not registered. |
@JanTvrdik could you show me an example? |
I want only reduce the exclude list, where you don't need to register services. |
The similar condition is \ReflectionClass($class)::isInstantiable(). |
This is an absolutely fatal BC break. |
Could you more explain the BC break to me, because I don't understand. |
Service B depends on service A Why? Services don't even have to come from the same repository so the developer doesn't have control over service A. Service B not being registered instead of reporting that A is missing even though developer configured search extension to find it is really confusing behavior. I am aware of this feature and was digging in Nette internals for 6 years now and I would still be lost if this happened to me. |
@mabar Thank you for explain I tried your example class A
{
public function __construct()
{
}
}
class B
{
public function __construct(private A $a)
{
}
}
Both classes are loaded by search extension and I get exception: A is regstered, B is loaded in config: B is registered, A is loaded: **Nette\DI\ServiceCreationException: These use cases have legit exception. Nothing about missing Garage\B. But in this case is little bit worse I revert A and add scalar parameter class A
{
public function __construct(string $foo)
{
}
} Nette\DI\ServiceCreationException: Service of type Garage\B: Service of type Garage\A required by $a in B::__construct() not found. Did you add it to configuration file? The response on question What do you think? |
Hello,
I use SearchExtension and I have primitive classes in project, but all these classes I must register to
exclude
section. I think if the class does not have autowired parameters it can be skipped.Example:
Simple class
Actual behavior throw exception:
In this moment I must add class to
search -> exclude
.New bahevior
If SearchExtension skip this class and I don't need dependency by another class, everything is ok.
If I need dependency by another class, for example
Garage\Model\Baz
. I get exception:I must manually register the class and I think it is legit. I can't think of a use case where it might be undesirable.
After apply this patch, the result is: