)) {
$xmlWriter->writeAttribute($name, $value);
} else {
$xmlWriter->writeAttributeNS($prefix, $name, $namespace, $value);
}
}
/**
* Write an element with namespace if used
*
* @param \XMLWriter $xmlWriter XML writer resource
* @param string $prefix Namespace prefix if any
* @param string $name Element name
* @param string $namespace The uri of the namespace
* @param string $value The element content
*/
protected function writeElement(\XMLWriter $xmlWriter, $prefix, $name, $namespace, $value)
{
$xmlWriter->startElementNS($prefix, $name, $namespace);
if (strpbrk($value, '<>&')) {
$xmlWriter->writeCData($value);
} else {
$xmlWriter->writeRaw($value);
}
$xmlWriter->endElement();
}
/**
* Create a new xml writer and start a document
*
* @param string $encoding document encoding
*
* @return \XMLWriter the writer resource
*/
protected function startDocument($encoding)
{
$xmlWriter = new \XMLWriter();
$xmlWriter->openMemory();
$xmlWriter->startDocument('1.0', $encoding);
return $xmlWriter;
}
/**
* End the document and return the output
*
* @param \XMLWriter $xmlWriter
*
* @return \string the writer resource
*/
protected function finishDocument($xmlWriter)
{
$xmlWriter->endDocument();
return $xmlWriter->outputMemory();
}
/**
* Add an array to the XML
*/
protected function addXmlArray(\XMLWriter $xmlWriter, Parameter $param, &$value)
{
if ($items = $param->getItems()) {
foreach ($value as $v) {
$this->addXml($xmlWriter, $items, $v);
}
}
}
/**
* Add an object to the XML
*/
protected function addXmlObject(\XMLWriter $xmlWriter, Parameter $param, &$value)
{
$noAttributes = array();
// add values which have attributes
foreach ($value as $name => $v) {
if ($property = $param->getProperty($name)) {
if ($property->getData('xmlAttribute')) {
$this->addXml($xmlWriter, $property, $v);
} else {
$noAttributes[] = array('value' => $v, 'property' => $property);
}
}
}
// now add values with no attributes
foreach ($noAttributes as $element) {
$this->addXml($xmlWriter, $element['property'], $element['value']);
}
}
}
HeaderVisitor.php 1529 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/LocationVisitor/Request filter($value);
if ($param->getType() == 'object' && $param->getAdditionalProperties() instanceof Parameter) {
$this->addPrefixedHeaders($request, $param, $value);
} else {
$request->setHeader($param->getWireName(), $value);
}
}
/**
* Add a prefixed array of headers to the request
*
* @param RequestInterface $request Request to update
* @param Parameter $param Parameter object
* @param array $value Header array to add
*
* @throws InvalidArgumentException
*/
protected function addPrefixedHeaders(RequestInterface $request, Parameter $param, $value)
{
if (!is_array($value)) {
throw new InvalidArgumentException('An array of mapped headers expected, but received a single value');
}
$prefix = $param->getSentAs();
foreach ($value as $headerName => $headerValue) {
$request->setHeader($prefix . $headerName, $headerValue);
}
}
}
VisitorFlyweight.php 4819 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/LocationVisitor 'Guzzle\Service\Command\LocationVisitor\Request\BodyVisitor',
'request.header' => 'Guzzle\Service\Command\LocationVisitor\Request\HeaderVisitor',
'request.json' => 'Guzzle\Service\Command\LocationVisitor\Request\JsonVisitor',
'request.postField' => 'Guzzle\Service\Command\LocationVisitor\Request\PostFieldVisitor',
'request.postFile' => 'Guzzle\Service\Command\LocationVisitor\Request\PostFileVisitor',
'request.query' => 'Guzzle\Service\Command\LocationVisitor\Request\QueryVisitor',
'request.response_body' => 'Guzzle\Service\Command\LocationVisitor\Request\ResponseBodyVisitor',
'request.responseBody' => 'Guzzle\Service\Command\LocationVisitor\Request\ResponseBodyVisitor',
'request.xml' => 'Guzzle\Service\Command\LocationVisitor\Request\XmlVisitor',
'response.body' => 'Guzzle\Service\Command\LocationVisitor\Response\BodyVisitor',
'response.header' => 'Guzzle\Service\Command\LocationVisitor\Response\HeaderVisitor',
'response.json' => 'Guzzle\Service\Command\LocationVisitor\Response\JsonVisitor',
'response.reasonPhrase' => 'Guzzle\Service\Command\LocationVisitor\Response\ReasonPhraseVisitor',
'response.statusCode' => 'Guzzle\Service\Command\LocationVisitor\Response\StatusCodeVisitor',
'response.xml' => 'Guzzle\Service\Command\LocationVisitor\Response\XmlVisitor'
);
/** @var array Array of mappings of location names to classes */
protected $mappings;
/** @var array Cache of instantiated visitors */
protected $cache = array();
/**
* @return self
* @codeCoverageIgnore
*/
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
/**
* @param array $mappings Array mapping request.name and response.name to location visitor classes. Leave null to
* use the default values.
*/
public function __construct(array $mappings = null)
{
$this->mappings = $mappings === null ? self::$defaultMappings : $mappings;
}
/**
* Get an instance of a request visitor by location name
*
* @param string $visitor Visitor name
*
* @return RequestVisitorInterface
*/
public function getRequestVisitor($visitor)
{
return $this->getKey('request.' . $visitor);
}
/**
* Get an instance of a response visitor by location name
*
* @param string $visitor Visitor name
*
* @return ResponseVisitorInterface
*/
public function getResponseVisitor($visitor)
{
return $this->getKey('response.' . $visitor);
}
/**
* Add a response visitor to the factory by name
*
* @param string $name Name of the visitor
* @param RequestVisitorInterface $visitor Visitor to add
*
* @return self
*/
public function addRequestVisitor($name, RequestVisitorInterface $visitor)
{
$this->cache['request.' . $name] = $visitor;
return $this;
}
/**
* Add a response visitor to the factory by name
*
* @param string $name Name of the visitor
* @param ResponseVisitorInterface $visitor Visitor to add
*
* @return self
*/
public function addResponseVisitor($name, ResponseVisitorInterface $visitor)
{
$this->cache['response.' . $name] = $visitor;
return $this;
}
/**
* Get a visitor by key value name
*
* @param string $key Key name to retrieve
*
* @return mixed
* @throws InvalidArgumentException
*/
private function getKey($key)
{
if (!isset($this->cache[$key])) {
if (!isset($this->mappings[$key])) {
list($type, $name) = explode('.', $key);
throw new InvalidArgumentException("No {$type} visitor has been mapped for {$name}");
}
$this->cache[$key] = new $this->mappings[$key];
}
return $this->cache[$key];
}
}
AbstractResponseVisitor.php 614 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/LocationVisitor/Response getName()] = $param->filter($response->getBody());
}
}
StatusCodeVisitor.php 578 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/LocationVisitor/Response getName()] = $response->getStatusCode();
}
}
ReasonPhraseVisitor.php 584 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/LocationVisitor/Response getName()] = $response->getReasonPhrase();
}
}
JsonVisitor.php 3514 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/LocationVisitor/Response getResponse()->json();
}
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]);
}
}
}
/**
* Recursively process a parameter while applying filters
*
* @param Parameter $param API parameter being validated
* @param mixed $value Value to validate and process. The value may change during this process.
*/
protected function recursiveProcess(Parameter $param, &$value)
{
if ($value === null) {
return;
}
if (is_array($value)) {
$type = $param->getType();
if ($type == 'array') {
foreach ($value as &$item) {
$this->recursiveProcess($param->getItems(), $item);
}
} elseif ($type == 'object' && !isset($value[0])) {
// On the above line, we ensure that the array is associative and not numerically indexed
$knownProperties = array();
if ($properties = $param->getProperties()) {
foreach ($properties as $property) {
$name = $property->getName();
$key = $property->getWireName();
$knownProperties[$name] = 1;
if (isset($value[$key])) {
$this->recursiveProcess($property, $value[$key]);
if ($key != $name) {
$value[$name] = $value[$key];
unset($value[$key]);
}
}
}
}
// Remove any unknown and potentially unsafe properties
if ($param->getAdditionalProperties() === false) {
$value = array_intersect_key($value, $knownProperties);
} elseif (($additional = $param->getAdditionalProperties()) !== true) {
// Validate and filter additional properties
foreach ($value as &$v) {
$this->recursiveProcess($additional, $v);
}
}
}
}
$value = $param->filter($value);
}
}
XmlVisitor.php 5584 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/LocationVisitor/Response getResponse()->xml()), true);
}
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]);
}
}
}
/**
* Recursively process a parameter while applying filters
*
* @param Parameter $param API parameter being processed
* @param mixed $value Value to validate and process. The value may change during this process.
*/
protected function recursiveProcess(Parameter $param, &$value)
{
$type = $param->getType();
if (!is_array($value)) {
if ($type == 'array') {
// Cast to an array if the value was a string, but should be an array
$this->recursiveProcess($param->getItems(), $value);
$value = array($value);
}
} elseif ($type == 'object') {
$this->processObject($param, $value);
} elseif ($type == 'array') {
$this->processArray($param, $value);
} elseif ($type == 'string' && gettype($value) == 'array') {
$value = '';
}
if ($value !== null) {
$value = $param->filter($value);
}
}
/**
* Process an array
*
* @param Parameter $param API parameter being parsed
* @param mixed $value Value to process
*/
protected function processArray(Parameter $param, &$value)
{
// Convert the node if it was meant to be an array
if (!isset($value[0])) {
// Collections fo nodes are sometimes wrapped in an additional array. For example:
// - 1
- 2
should become:
// array('Items' => array(array('a' => 1), array('a' => 2))
// Some nodes are not wrapped. For example: 12
// should become array('Foo' => array(array('a' => 1), array('a' => 2))
if ($param->getItems() && isset($value[$param->getItems()->getWireName()])) {
// Account for the case of a collection wrapping wrapped nodes: Items => Item[]
$value = $value[$param->getItems()->getWireName()];
// If the wrapped node only had one value, then make it an array of nodes
if (!isset($value[0]) || !is_array($value)) {
$value = array($value);
}
} elseif (!empty($value)) {
// Account for repeated nodes that must be an array: Foo => Baz, Foo => Baz, but only if the
// value is set and not empty
$value = array($value);
}
}
foreach ($value as &$item) {
$this->recursiveProcess($param->getItems(), $item);
}
}
/**
* Process an object
*
* @param Parameter $param API parameter being parsed
* @param mixed $value Value to process
*/
protected function processObject(Parameter $param, &$value)
{
// Ensure that the array is associative and not numerically indexed
if (!isset($value[0]) && ($properties = $param->getProperties())) {
$knownProperties = array();
foreach ($properties as $property) {
$name = $property->getName();
$sentAs = $property->getWireName();
$knownProperties[$name] = 1;
if ($property->getData('xmlAttribute')) {
$this->processXmlAttribute($property, $value);
} elseif (isset($value[$sentAs])) {
$this->recursiveProcess($property, $value[$sentAs]);
if ($name != $sentAs) {
$value[$name] = $value[$sentAs];
unset($value[$sentAs]);
}
}
}
// Remove any unknown and potentially unsafe properties
if ($param->getAdditionalProperties() === false) {
$value = array_intersect_key($value, $knownProperties);
}
}
}
/**
* Process an XML attribute property
*
* @param Parameter $property Property to process
* @param array $value Value to process and update
*/
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']);
}
}
}
}
HeaderVisitor.php 1814 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/LocationVisitor/Response getType() == 'object' && $param->getAdditionalProperties() instanceof Parameter) {
$this->processPrefixedHeaders($response, $param, $value);
} else {
$value[$param->getName()] = $param->filter((string) $response->getHeader($param->getWireName()));
}
}
/**
* Process a prefixed header array
*
* @param Response $response Response that contains the headers
* @param Parameter $param Parameter object
* @param array $value Value response array to modify
*/
protected function processPrefixedHeaders(Response $response, Parameter $param, &$value)
{
// Grab prefixed headers that should be placed into an array with the prefix stripped
if ($prefix = $param->getSentAs()) {
$container = $param->getName();
$len = strlen($prefix);
// Find all matching headers and place them into the containing element
foreach ($response->getHeaders()->toArray() as $key => $header) {
if (stripos($key, $prefix) === 0) {
// Account for multi-value headers
$value[$container][substr($key, $len)] = count($header) == 1 ? end($header) : $header;
}
}
}
}
}
ServiceDescriptionFactory.php 2157 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/Factory setServiceDescription($description);
$this->inflector = $inflector;
}
/**
* Change the service description used with the factory
*
* @param ServiceDescriptionInterface $description Service description to use
*
* @return FactoryInterface
*/
public function setServiceDescription(ServiceDescriptionInterface $description)
{
$this->description = $description;
return $this;
}
/**
* Returns the service description
*
* @return ServiceDescriptionInterface
*/
public function getServiceDescription()
{
return $this->description;
}
public function factory($name, array $args = array())
{
$command = $this->description->getOperation($name);
// If a command wasn't found, then try to uppercase the first letter and try again
if (!$command) {
$command = $this->description->getOperation(ucfirst($name));
// If an inflector was passed, then attempt to get the command using snake_case inflection
if (!$command && $this->inflector) {
$command = $this->description->getOperation($this->inflector->snake($name));
}
}
if ($command) {
$class = $command->getClass();
return new $class($args, $command, $this->description);
}
}
}
AliasFactory.php 1120 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/Factory client = $client;
$this->aliases = $aliases;
}
public function factory($name, array $args = array())
{
if (isset($this->aliases[$name])) {
try {
return $this->client->getCommand($this->aliases[$name], $args);
} catch (InvalidArgumentException $e) {
return null;
}
}
}
}
ConcreteClassFactory.php 1605 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/Factory client = $client;
$this->inflector = $inflector ?: Inflector::getDefault();
}
public function factory($name, array $args = array())
{
// Determine the class to instantiate based on the namespace of the current client and the default directory
$prefix = $this->client->getConfig('command.prefix');
if (!$prefix) {
// The prefix can be specified in a factory method and is cached
$prefix = implode('\\', array_slice(explode('\\', get_class($this->client)), 0, -1)) . '\\Command\\';
$this->client->getConfig()->set('command.prefix', $prefix);
}
$class = $prefix . str_replace(' ', '\\', ucwords(str_replace('.', ' ', $this->inflector->camel($name))));
// Create the concrete command if it exists
if (class_exists($class)) {
return new $class($args);
}
}
}
MapFactory.php 639 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/Factory map = $map;
}
public function factory($name, array $args = array())
{
if (isset($this->map[$name])) {
$class = $this->map[$name];
return new $class($args);
}
}
}
CompositeFactory.php 4122 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/Factory getDescription()) {
$factories[] = new ServiceDescriptionFactory($description);
}
$factories[] = new ConcreteClassFactory($client);
return new self($factories);
}
/**
* @param array $factories Array of command factories
*/
public function __construct(array $factories = array())
{
$this->factories = $factories;
}
/**
* Add a command factory to the chain
*
* @param FactoryInterface $factory Factory to add
* @param string|FactoryInterface $before Insert the new command factory before a command factory class or object
* matching a class name.
* @return CompositeFactory
*/
public function add(FactoryInterface $factory, $before = null)
{
$pos = null;
if ($before) {
foreach ($this->factories as $i => $f) {
if ($before instanceof FactoryInterface) {
if ($f === $before) {
$pos = $i;
break;
}
} elseif (is_string($before)) {
if ($f instanceof $before) {
$pos = $i;
break;
}
}
}
}
if ($pos === null) {
$this->factories[] = $factory;
} else {
array_splice($this->factories, $i, 0, array($factory));
}
return $this;
}
/**
* Check if the chain contains a specific command factory
*
* @param FactoryInterface|string $factory Factory to check
*
* @return bool
*/
public function has($factory)
{
return (bool) $this->find($factory);
}
/**
* Remove a specific command factory from the chain
*
* @param string|FactoryInterface $factory Factory to remove by name or instance
*
* @return CompositeFactory
*/
public function remove($factory = null)
{
if (!($factory instanceof FactoryInterface)) {
$factory = $this->find($factory);
}
$this->factories = array_values(array_filter($this->factories, function($f) use ($factory) {
return $f !== $factory;
}));
return $this;
}
/**
* Get a command factory by class name
*
* @param string|FactoryInterface $factory Command factory class or instance
*
* @return null|FactoryInterface
*/
public function find($factory)
{
foreach ($this->factories as $f) {
if ($factory === $f || (is_string($factory) && $f instanceof $factory)) {
return $f;
}
}
}
/**
* Create a command using the associated command factories
*
* @param string $name Name of the command
* @param array $args Command arguments
*
* @return CommandInterface
*/
public function factory($name, array $args = array())
{
foreach ($this->factories as $factory) {
$command = $factory->factory($name, $args);
if ($command) {
return $command;
}
}
}
public function count()
{
return count($this->factories);
}
public function getIterator()
{
return new \ArrayIterator($this->factories);
}
}
FactoryInterface.php 426 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command/Factory operation = $operation ?: $this->createOperation();
foreach ($this->operation->getParams() as $name => $arg) {
$currentValue = $this[$name];
$configValue = $arg->getValue($currentValue);
// If default or static values are set, then this should always be updated on the config object
if ($currentValue !== $configValue) {
$this[$name] = $configValue;
}
}
$headers = $this[self::HEADERS_OPTION];
if (!$headers instanceof Collection) {
$this[self::HEADERS_OPTION] = new Collection((array) $headers);
}
// You can set a command.on_complete option in your parameters to set an onComplete callback
if ($onComplete = $this['command.on_complete']) {
unset($this['command.on_complete']);
$this->setOnComplete($onComplete);
}
// Set the hidden additional parameters
if (!$this[self::HIDDEN_PARAMS]) {
$this[self::HIDDEN_PARAMS] = array(
self::HEADERS_OPTION,
self::RESPONSE_PROCESSING,
self::HIDDEN_PARAMS,
self::REQUEST_OPTIONS
);
}
$this->init();
}
/**
* Custom clone behavior
*/
public function __clone()
{
$this->request = null;
$this->result = null;
}
/**
* Execute the command in the same manner as calling a function
*
* @return mixed Returns the result of {@see AbstractCommand::execute}
*/
public function __invoke()
{
return $this->execute();
}
public function getName()
{
return $this->operation->getName();
}
/**
* Get the API command information about the command
*
* @return OperationInterface
*/
public function getOperation()
{
return $this->operation;
}
public function setOnComplete($callable)
{
if (!is_callable($callable)) {
throw new InvalidArgumentException('The onComplete function must be callable');
}
$this->onComplete = $callable;
return $this;
}
public function execute()
{
if (!$this->client) {
throw new CommandException('A client must be associated with the command before it can be executed.');
}
return $this->client->execute($this);
}
public function getClient()
{
return $this->client;
}
public function setClient(ClientInterface $client)
{
$this->client = $client;
return $this;
}
public function getRequest()
{
if (!$this->request) {
throw new CommandException('The command must be prepared before retrieving the request');
}
return $this->request;
}
public function getResponse()
{
if (!$this->isExecuted()) {
$this->execute();
}
return $this->request->getResponse();
}
public function getResult()
{
if (!$this->isExecuted()) {
$this->execute();
}
if (null === $this->result) {
$this->process();
// Call the onComplete method if one is set
if ($this->onComplete) {
call_user_func($this->onComplete, $this);
}
}
return $this->result;
}
public function setResult($result)
{
$this->result = $result;
return $this;
}
public function isPrepared()
{
return $this->request !== null;
}
public function isExecuted()
{
return $this->request !== null && $this->request->getState() == 'complete';
}
public function prepare()
{
if (!$this->isPrepared()) {
if (!$this->client) {
throw new CommandException('A client must be associated with the command before it can be prepared.');
}
// If no response processing value was specified, then attempt to use the highest level of processing
if (!isset($this[self::RESPONSE_PROCESSING])) {
$this[self::RESPONSE_PROCESSING] = self::TYPE_MODEL;
}
// Notify subscribers of the client that the command is being prepared
$this->client->dispatch('command.before_prepare', array('command' => $this));
// Fail on missing required arguments, and change parameters via filters
$this->validate();
// Delegate to the subclass that implements the build method
$this->build();
// Add custom request headers set on the command
if ($headers = $this[self::HEADERS_OPTION]) {
foreach ($headers as $key => $value) {
$this->request->setHeader($key, $value);
}
}
// Add any curl options to the request
if ($options = $this[Client::CURL_OPTIONS]) {
$this->request->getCurlOptions()->overwriteWith(CurlHandle::parseCurlConfig($options));
}
// Set a custom response body
if ($responseBody = $this[self::RESPONSE_BODY]) {
$this->request->setResponseBody($responseBody);
}
$this->client->dispatch('command.after_prepare', array('command' => $this));
}
return $this->request;
}
/**
* Set the validator used to validate and prepare command parameters and nested JSON schemas. If no validator is
* set, then the command will validate using the default {@see SchemaValidator}.
*
* @param ValidatorInterface $validator Validator used to prepare and validate properties against a JSON schema
*
* @return self
*/
public function setValidator(ValidatorInterface $validator)
{
$this->validator = $validator;
return $this;
}
public function getRequestHeaders()
{
return $this[self::HEADERS_OPTION];
}
/**
* Initialize the command (hook that can be implemented in subclasses)
*/
protected function init() {}
/**
* Create the request object that will carry out the command
*/
abstract protected function build();
/**
* Hook used to create an operation for concrete commands that are not associated with a service description
*
* @return OperationInterface
*/
protected function createOperation()
{
return new Operation(array('name' => get_class($this)));
}
/**
* Create the result of the command after the request has been completed.
* Override this method in subclasses to customize this behavior
*/
protected function process()
{
$this->result = $this[self::RESPONSE_PROCESSING] != self::TYPE_RAW
? DefaultResponseParser::getInstance()->parse($this)
: $this->request->getResponse();
}
/**
* Validate and prepare the command based on the schema and rules defined by the command's Operation object
*
* @throws ValidationException when validation errors occur
*/
protected function validate()
{
// Do not perform request validation/transformation if it is disable
if ($this[self::DISABLE_VALIDATION]) {
return;
}
$errors = array();
$validator = $this->getValidator();
foreach ($this->operation->getParams() as $name => $schema) {
$value = $this[$name];
if (!$validator->validate($schema, $value)) {
$errors = array_merge($errors, $validator->getErrors());
} elseif ($value !== $this[$name]) {
// Update the config value if it changed and no validation errors were encountered
$this->data[$name] = $value;
}
}
// Validate additional parameters
$hidden = $this[self::HIDDEN_PARAMS];
if ($properties = $this->operation->getAdditionalParameters()) {
foreach ($this->toArray() as $name => $value) {
// It's only additional if it isn't defined in the schema
if (!$this->operation->hasParam($name) && !in_array($name, $hidden)) {
// Always set the name so that error messages are useful
$properties->setName($name);
if (!$validator->validate($properties, $value)) {
$errors = array_merge($errors, $validator->getErrors());
} elseif ($value !== $this[$name]) {
$this->data[$name] = $value;
}
}
}
}
if (!empty($errors)) {
$e = new ValidationException('Validation errors: ' . implode("\n", $errors));
$e->setErrors($errors);
throw $e;
}
}
/**
* Get the validator used to prepare and validate properties. If no validator has been set on the command, then
* the default {@see SchemaValidator} will be used.
*
* @return ValidatorInterface
*/
protected function getValidator()
{
if (!$this->validator) {
$this->validator = SchemaValidator::getInstance();
}
return $this->validator;
}
/**
* Get array of any validation errors
* If no validator has been set then return false
*/
public function getValidationErrors()
{
if (!$this->validator) {
return false;
}
return $this->validator->getErrors();
}
}
OperationCommand.php 2523 1503599154 plugins/updraftplus/vendor/guzzle/guzzle/src/Guzzle/Service/Command