initial commit
This commit is contained in:
32
vendor/symfony/maker-bundle/templates/serializer/Encoder.tpl.php
vendored
Normal file
32
vendor/symfony/maker-bundle/templates/serializer/Encoder.tpl.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?= "<?php\n" ?>
|
||||
|
||||
namespace <?= $namespace; ?>;
|
||||
|
||||
<?= $use_statements; ?>
|
||||
|
||||
class <?= $class_name ?> implements EncoderInterface, DecoderInterface
|
||||
{
|
||||
public const FORMAT = '<?= $format ?>';
|
||||
|
||||
public function encode(mixed $data, string $format, array $context = []): string
|
||||
{
|
||||
// TODO: return your encoded data
|
||||
return '';
|
||||
}
|
||||
|
||||
public function supportsEncoding(string $format): bool
|
||||
{
|
||||
return self::FORMAT === $format;
|
||||
}
|
||||
|
||||
public function decode(string $data, string $format, array $context = [])<?php if ($use_decoder_return_type): ?>: mixed<?php endif; ?>
|
||||
{
|
||||
// TODO: return your decoded data
|
||||
return '';
|
||||
}
|
||||
|
||||
public function supportsDecoding(string $format): bool
|
||||
{
|
||||
return self::FORMAT === $format;
|
||||
}
|
||||
}
|
||||
41
vendor/symfony/maker-bundle/templates/serializer/Normalizer.tpl.php
vendored
Normal file
41
vendor/symfony/maker-bundle/templates/serializer/Normalizer.tpl.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?= "<?php\n" ?>
|
||||
|
||||
namespace <?= $namespace; ?>;
|
||||
|
||||
<?= $use_statements; ?>
|
||||
|
||||
class <?= $class_name ?> implements NormalizerInterface
|
||||
{
|
||||
public function __construct(
|
||||
#[Autowire(service: 'serializer.normalizer.object')]
|
||||
private NormalizerInterface $normalizer
|
||||
) {
|
||||
}
|
||||
|
||||
public function normalize($object, ?string $format = null, array $context = []): array
|
||||
{
|
||||
$data = $this->normalizer->normalize($object, $format, $context);
|
||||
|
||||
// TODO: add, edit, or delete some data
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
<?php if ($entity_exists): ?>
|
||||
return $data instanceof <?= $entity_name ?>;
|
||||
<?php else: ?>
|
||||
// TODO: return $data instanceof Object
|
||||
<?php endif ?>
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
<?php if ($entity_exists): ?>
|
||||
return [<?= $entity_name ?>::class => true];
|
||||
<?php else: ?>
|
||||
// TODO: return [Object::class => true];
|
||||
<?php endif ?>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user