これは の定義 (の一部) でありBaseOperation
、1 つの必須パラメーター ( 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
。
編集: HTTP 動詞との混乱を避けるために、param 名を「method」から「foo」に変更しました。