本文整理汇总了PHP中Guzzle\Service\Description\Parameter::getWireName方法的典型用法代码示例。如果您正苦于以下问题:PHP Parameter::getWireName方法的具体用法?PHP Parameter::getWireName怎么用?PHP Parameter::getWireName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Service\Description\Parameter
的用法示例。
在下文中一共展示了Parameter::getWireName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addXml
protected function addXml(\XMLWriter $xmlWriter, Parameter $param, $value)
{
if ($value === null) {
return;
}
$value = $param->filter($value);
$type = $param->getType();
$name = $param->getWireName();
$prefix = null;
$namespace = $param->getData('xmlNamespace');
if (false !== strpos($name, ':')) {
list($prefix, $name) = explode(':', $name, 2);
}
if ($type == 'object' || $type == 'array') {
if (!$param->getData('xmlFlattened')) {
$xmlWriter->startElementNS(null, $name, $namespace);
}
if ($param->getType() == 'array') {
$this->addXmlArray($xmlWriter, $param, $value);
} elseif ($param->getType() == 'object') {
$this->addXmlObject($xmlWriter, $param, $value);
}
if (!$param->getData('xmlFlattened')) {
$xmlWriter->endElement();
}
return;
}
if ($param->getData('xmlAttribute')) {
$this->writeAttribute($xmlWriter, $prefix, $name, $namespace, $value);
} else {
$this->writeElement($xmlWriter, $prefix, $name, $namespace, $value);
}
}
示例2: visit
/**
* {@inheritdoc}
*/
public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
{
if ($value instanceof PostFileInterface) {
$request->addPostFile($value);
} else {
$request->addPostFile($param->getWireName(), $value);
}
}
示例3: visit
public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
{
if (isset($this->data[$command])) {
$json = $this->data[$command];
} else {
$json = array();
}
$json[$param->getWireName()] = $this->prepareValue($value, $param);
$this->data[$command] = $json;
}
示例4: visit
/**
* {@inheritdoc}
*/
public function visit(CommandInterface $command, Response $response, Parameter $param, &$value, $context = null)
{
// check if there's a link provided for the param's "wire" name
$links = $this->get($command, 'links');
if (!empty($links[$param->getWireName()])) {
// create a command representing the link
$linkCommand = $this->builder->createLinkCommand($command, $param, $links[$param->getWireName()]);
// store the created link command in the results array
$value[self::ELEMENT][$param->getName()] = $linkCommand;
}
}
示例5: processXmlAttribute
protected function processXmlAttribute(Parameter $property, array &$value)
{
$sentAs = $property->getWireName();
if (isset($value['@attributes'][$sentAs])) {
$value[$property->getName()] = $value['@attributes'][$sentAs];
unset($value['@attributes'][$sentAs]);
if (empty($value['@attributes'])) {
unset($value['@attributes']);
}
}
}
示例6: visit
/**
* {@inheritdoc}
*/
public function visit(CommandInterface $command, Response $response, Parameter $param, &$value, $context = null)
{
// check if there's embedded resource data for the parameter
$resourceData = $this->get($command, $this->getFieldName());
if (!empty($resourceData[$param->getWireName()])) {
// create the resource representing the embedded resource data
$resource = $this->createResourceFromData($command, $param, $resourceData[$param->getWireName()]);
// store the created embedded resource in the results array
$value[$this->getOutputFieldName()][$param->getName()] = $resource;
}
}
示例7: visit
public function visit(CommandInterface $command, Response $response, Parameter $param, &$value, $context = null)
{
$name = $param->getName();
$key = $param->getWireName();
if (isset($value[$key])) {
$this->recursiveProcess($param, $value[$key]);
if ($key != $name) {
$value[$name] = $value[$key];
unset($value[$key]);
}
}
}
示例8: visit
/**
* {@inheritdoc}
*/
public function visit(CommandInterface $command, Response $response, Parameter $param, &$value, $context = null)
{
// check if there's an embedded resource for the parameter's
// "wire" name
$resources = $this->get($command, 'embedded');
if (!empty($resources[$param->getWireName()])) {
// create a model representing the embedded resource data
$embeddedModel = $this->builder->createEmbeddedModel($command, $param, $resources[$param->getWireName()]);
// store the created embedded model in the results array
$value[self::ELEMENT][$param->getName()] = $embeddedModel;
}
}
示例9: visit
/**
* {@inheritdoc}
*/
public function visit(CommandInterface $command, Response $response, Parameter $param, &$value, $context = null)
{
$sentAs = $param->getWireName();
$name = $param->getName();
if (isset($value[$sentAs])) {
$this->recursiveProcess($param, $value[$sentAs]);
if ($name != $sentAs) {
$value[$name] = $value[$sentAs];
unset($value[$sentAs]);
}
} elseif ($param->getType() == 'array') {
// Use a default array when the value is missing
$value[$name] = array();
} elseif ($param->getType() == 'boolean') {
// Use a default value of false when the value is missing
$value[$name] = false;
}
}
示例10: visit
public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
{
$request->getQuery()->set($param->getWireName(), $this->prepareValue($value, $param));
}
示例11: testHasKeyMethod
public function testHasKeyMethod()
{
$p = new Parameter(array('name' => 'foo', 'sentAs' => 'bar'));
$this->assertEquals('bar', $p->getWireName());
$p->setSentAs(null);
$this->assertEquals('foo', $p->getWireName());
}
示例12: addXml
/**
* Recursively build the XML body
*
* @param \SimpleXMLElement $xml XML to modify
* @param Parameter $param API Parameter
* @param mixed $value Value to add
*/
protected function addXml(\SimpleXMLElement $xml, Parameter $param, $value)
{
if ($value === null) {
return;
}
$value = $param->filter($value);
$type = $param->getType();
if ($type == 'object' || $type == 'array') {
$ele = $param->getData('xmlFlattened') ? $xml : $xml->addChild($param->getWireName());
if ($param->getType() == 'array') {
$this->addXmlArray($ele, $param, $value, $param->getData('xmlNamespace'));
} elseif ($param->getType() == 'object') {
$this->addXmlObject($ele, $param, $value);
}
} elseif ($param->getData('xmlAttribute')) {
$xml->addAttribute($param->getWireName(), $value, $param->getData('xmlNamespace'));
} else {
$xml->addChild($param->getWireName(), $value, $param->getData('xmlNamespace'));
}
}
示例13: visit
/**
* {@inheritdoc}
*/
public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
{
$json = isset($this->data[$command]) ? $this->data[$command] : array();
$json[$param->getWireName()] = $param && is_array($value) ? $this->resolveRecursively($value, $param) : $value;
$this->data[$command] = $json;
}
示例14: addXml
/**
* Recursively build the XML body
*
* @param \SimpleXMLElement $xml XML to modify
* @param Parameter $param API Parameter
* @param mixed $value Value to add
*/
protected function addXml(\SimpleXMLElement $xml, Parameter $param, $value)
{
// Determine the name of the element
$node = $param->getWireName();
// Check if this property has a particular namespace
$namespace = $param->getData('xmlNamespace');
// Filter the value
$value = $param->filter($value);
if ($param->getType() == 'array') {
$this->addXmlArray($xml, $param, $value, $namespace);
} elseif ($param->getType() == 'object') {
$this->addXmlObject($xml, $param, $value);
} elseif ($param->getData('xmlAttribute')) {
$xml->addAttribute($node, $value, $namespace);
} else {
$xml->addChild($node, $value, $namespace);
}
}
示例15: visit
/**
* {@inheritdoc}
*/
public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
{
$request->getQuery()->set($param->getWireName(), $param && is_array($value) ? $this->resolveRecursively($value, $param) : $value);
}