这是 的(部分)定义BaseOperation
,带有一个强制参数(foo
):
'BaseOperation' => array(
'class' => 'My\Command\MyCustomCommand',
'httpMethod' => 'POST',
'parameters' => array(
'foo' => array(
'required' => true,
'location' => 'query'
)
)
)
在ChangeMethodPlugin
插件里面我需要foo
在运行时修改的值:
class ChangeMethodPlugin implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return array('command.before_send' => 'onBeforeCommandSend');
}
public function onBeforeCommandSend(Event $event)
{
/** @var \Guzzle\Service\Command\CommandInterface $command */
$command = $event['command'];
// Only if test configuration is true
if ($command->getClient()->getConfig(ClientOptions::TEST)) {
// Only if command is MyCustomCommand
if ($command instanceof MyCustomCommand) {
// Here I need to change the value of 'foo' parameter
}
}
}
}
我在里面找不到任何方法Parameter
or AbstractCommand
。
编辑:参数名称从“方法”更改为“foo”以避免与 HTTP 动词混淆。