Comments (4)
Meanwhile I have a workaround:
$emitter = $this->client->getEmitter();
foreach ($emitter->listeners() as $listeners)
{
foreach ($listeners as $listener)
{
if ($listener[0] instanceof PrepareRequest)
{
$emitter->detach($listener[0]);
$emitter->attach(new PrepareRequest(array("path" => new PathLocation('path'))));
break;
}
}
}
with the following PathLocation implementation (using underscores for the placeholder)
namespace XYZ;
use GuzzleHttp\Command\Guzzle\Parameter;
use GuzzleHttp\Message\RequestInterface;
use GuzzleHttp\Command\Guzzle\Operation;
use GuzzleHttp\Command\Guzzle\GuzzleCommandInterface;
use GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation;
/**
* Inserts url path parameters.
*
*/
class PathLocation extends AbstractLocation
{
public function visit(
GuzzleCommandInterface $command,
RequestInterface $request,
Parameter $param,
array $context
) {
$value = $this->prepareValue(
$command[$param->getName()],
$param
);
$this->replaceParam($request, $param->getWireName(), $value);
}
public function after(
GuzzleCommandInterface $command,
RequestInterface $request,
Operation $operation,
array $context
) {
return;
$additional = $operation->getAdditionalParameters();
if ($additional && $additional->getLocation() == $this->locationName) {
foreach ($command->toArray() as $key => $value) {
if (!$operation->hasParam($key)) {
$this->replaceParam($request, $key, $this->prepareValue(
$value,
$additional
));
}
}
}
}
private function replaceParam(RequestInterface $request, $name, $value)
{
$path = str_replace('_' . $name . '_', $value, $request->getPath());
$request->setPath($path);
}
}
from guzzle-services.
You can just use the uri template functionality of Guzzle and set the location of the parameter to "uri".
from guzzle-services.
Many thanks, that fixed it. No code necessary. Since I have been (and still am) too dumb to find the proper place in the documentation, I quickly hacked the readme.
from guzzle-services.
Thanks again. I'm closing this.
from guzzle-services.
Related Issues (20)
- Recommended test setup? HOT 1
- Unable to POST multipart parameters HOT 1
- Is there a way to put other models definition for list items ? HOT 1
- Raw request body data HOT 3
- What am i doing wrong ? HOT 3
- Please document how to use middleware with GuzzleClient HOT 1
- Better responseModel/responseClass feature. HOT 2
- Create request without root key HOT 1
- Support for Multiple `type` Options within Response Models
- Tests Fail with guzzlehttp/psr7 >= 1.6.0 HOT 1
- Feature Request - Ability to Bind Parameter Filters to Specific Request Stages
- What branch is under active development? HOT 2
- Feature Request: Ability to Specify "process: false" at Operation Level
- State of the project HOT 8
- guzzlehttp/guzzle dosn't work after update php to php 8 HOT 2
- Not possible to install on PHP <=7.3 HOT 2
- Why headers are not being passed ?
- Ran into composer issue because package does not auto update. HOT 5
- Extending a parameter that extends another parameter doesn't work as expected
- Add default property into response model HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guzzle-services.