You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, thank you for the great project! I am trying to invoke PhpDA from within another console application and thus not directly using the CLI scripts the project provides. What I would like to do now is to define a more sophisticated ReferenceValidator that requires some configuration at runtime.
Currently, the ReferenceValidator does not support constructor-injection, as the validator is simply instantiated by the plugin loader (which is totally fine for the CLI usage). Also, it is not possible to somehow get the instantiated ReferenceValidator by the API and therefore it is also not possible to use setter-injection.
A simple way to enable either-or is to change the current config implementation as follows:
public function getReferenceValidator()
{
if (!is_null($this->referenceValidator) && !is_string($this->referenceValidator) && !($this->referenceValidator instanceof ValidatorInterface)) {
throw new \InvalidArgumentException('Config for referenceValidator must be an string');
}
return $this->referenceValidator;
}
The plugin loader would then need to check whether there is already an object coming from the config and then skip instantiation. I guess the proposed approach seems a bit like a workaround, but it should work at least :-).
What do you think? If the proposed approach is fine for you I'd be happy to help with the implementation!
The text was updated successfully, but these errors were encountered:
Hey, thank you for the great project! I am trying to invoke PhpDA from within another console application and thus not directly using the CLI scripts the project provides. What I would like to do now is to define a more sophisticated
ReferenceValidator
that requires some configuration at runtime.Currently, the
ReferenceValidator
does not support constructor-injection, as the validator is simply instantiated by the plugin loader (which is totally fine for the CLI usage). Also, it is not possible to somehow get the instantiated ReferenceValidator by the API and therefore it is also not possible to use setter-injection.A simple way to enable either-or is to change the current config implementation as follows:
The plugin loader would then need to check whether there is already an object coming from the config and then skip instantiation. I guess the proposed approach seems a bit like a workaround, but it should work at least :-).
What do you think? If the proposed approach is fine for you I'd be happy to help with the implementation!
The text was updated successfully, but these errors were encountered: