mirror of
https://github.com/linuxserver/Heimdall.git
synced 2026-08-07 07:16:13 +00:00
d16b7f60f3
The WebSocket support added for TrueNAS JSON-RPC 2.0 requires the phrity/websocket library to actually be available at runtime. This repo commits the vendor/ tree (CI does not run composer install), so the dependency and composer.lock must be committed for class_exists() checks in the TrueNAS app to succeed. - composer require phrity/websocket:^3.6 (resolves to 3.7.3) with lock and vendor/ committed - Fix TrueNASWebSocketClient to catch WebSocket\Exception\Exception (phrity/websocket v3 namespace) instead of the non-existent WebSocket\ConnectionException from the old textalk/websocket v1/v2 API, so connection/call failures are logged and wrapped as intended
37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Phrity\Util\Transformer\Symfony;
|
|
|
|
use Phrity\Util\Transformer\{
|
|
TransformerException,
|
|
TransformerInterface,
|
|
Type,
|
|
};
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
|
|
class NormalizerWrapper implements TransformerInterface
|
|
{
|
|
public function __construct(
|
|
private NormalizerInterface $normalizer,
|
|
) {
|
|
}
|
|
|
|
public function canTransform(mixed $subject, string|null $type = null): bool
|
|
{
|
|
if (!$this->normalizer->supportsNormalization($subject)) {
|
|
return false;
|
|
}
|
|
return in_array($type, [null, gettype($this->normalizer->normalize($subject))]);
|
|
}
|
|
|
|
public function transform(mixed $subject, string|null $type = null): mixed
|
|
{
|
|
if (!$this->canTransform($subject, $type)) {
|
|
$subjectType = get_debug_type($subject);
|
|
$class = get_debug_type($this->normalizer);
|
|
throw new TransformerException("Normalizer {$class} to not support '{$subjectType}'.");
|
|
}
|
|
return $this->normalizer->normalize($subject);
|
|
}
|
|
}
|