Server IP : 184.154.167.98 / Your IP : 3.145.1.182 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 8.2.26 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/puertode/public_html/sesiones/3rdparty/php-opencloud/openstack/src/Images/v2/ |
Upload File : |
<?php declare(strict_types=1); namespace OpenStack\Images\v2; class JsonPatch extends \OpenStack\Common\JsonSchema\JsonPatch { public function disableRestrictedPropRemovals(array $diff, array $restrictedProps): array { foreach ($diff as $i => $changeSet) { if ('remove' == $changeSet['op'] && in_array($changeSet['path'], $restrictedProps)) { unset($diff[$i]); } } return $diff; } /** * {@inheritdoc} * * We need to override the proper way to handle objects because Glance v2 does not * support whole document replacement with empty JSON pointers. */ protected function handleObject(\stdClass $srcStruct, \stdClass $desStruct, string $path): array { $changes = []; foreach ($desStruct as $key => $val) { if (!property_exists($srcStruct, $key)) { $changes[] = $this->makePatch(self::OP_ADD, $this->path($path, $key), $val); } elseif ($srcStruct->$key != $val) { $changes = array_merge($changes, $this->makeDiff($srcStruct->$key, $val, $this->path($path, $key))); } } if ($this->shouldPartiallyReplace($desStruct, $srcStruct)) { foreach ($srcStruct as $key => $val) { if (!property_exists($desStruct, $key)) { $changes[] = $this->makePatch(self::OP_REMOVE, $this->path($path, $key)); } } } return $changes; } protected function handleArray(array $srcStruct, array $desStruct, string $path): array { $changes = []; if ($srcStruct != $desStruct) { if ($diff = $this->arrayDiff($desStruct, $srcStruct)) { $changes[] = $this->makePatch(self::OP_REPLACE, $path, $desStruct); } foreach ($srcStruct as $key => $val) { if (!in_array($val, $desStruct, true)) { $changes[] = $this->makePatch(self::OP_REMOVE, $this->path($path, $key)); } } } return $changes; } }