-
Notifications
You must be signed in to change notification settings - Fork 730
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
Create transport from class which don't has prefix name Elastica\Transport #1169
Create transport from class which don't has prefix name Elastica\Transport #1169
Conversation
…sport Allow we store configuration in json format, and simply restore to in-memory array and pass to Elastica\Client.
I don't fully understand this change yet. Can you share some more details and example on this? |
Assume we define configuration of Elastica in JSON format. // config.json
We can simply call For example: <?php
$data = file_get_contents('/path/to/config.json');
$config = json_decode($data, true);
$client = new Elastica\Client($config); |
|
||
if (!class_exists($className)) { | ||
throw new InvalidException('Invalid transport'); | ||
$classNames = ["Elastica\\Transport\\$transport", $transport]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kind of thinking if we should turn this around. Have the base assumption that $transport is the full class name, and only have as fall back the Elastica once. I would have to check where in our code we would have to adjust these paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could check whether namespace separator () exists or not? It means it could be FQCN or built-in transport of Elastica right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check namespace seperator is bad idea, We should not assume that class has a namespace.
Nice, I was never thinking of this use case. I left some minor comments in the PR. Could you also update the CHANGELOG.md? |
@ruflin I have updated this PR for adding changelog. |
@Gasol Thanks, merged. |
Allow we store configuration in JSON format, and simply restore to in-memory array and pass to Elastica\Client.