Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
101 lines
3.3 KiB
PHP
101 lines
3.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Component\Serializer\Encoder;
|
|
|
|
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
|
use Symfony\Component\Serializer\Exception\RuntimeException;
|
|
use Symfony\Component\Yaml\Dumper;
|
|
use Symfony\Component\Yaml\Exception\ParseException;
|
|
use Symfony\Component\Yaml\Parser;
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
|
/**
|
|
* Encodes YAML data.
|
|
*
|
|
* @author Kévin Dunglas <dunglas@gmail.com>
|
|
*/
|
|
class YamlEncoder implements EncoderInterface, DecoderInterface
|
|
{
|
|
public const FORMAT = 'yaml';
|
|
private const ALTERNATIVE_FORMAT = 'yml';
|
|
|
|
public const PRESERVE_EMPTY_OBJECTS = 'preserve_empty_objects';
|
|
|
|
/**
|
|
* Override the amount of spaces to use for indentation of nested nodes.
|
|
*
|
|
* This option only works in the constructor, not in calls to `encode`.
|
|
*/
|
|
public const YAML_INDENTATION = 'yaml_indentation';
|
|
|
|
public const YAML_INLINE = 'yaml_inline';
|
|
/**
|
|
* Initial indentation for root element.
|
|
*/
|
|
public const YAML_INDENT = 'yaml_indent';
|
|
public const YAML_FLAGS = 'yaml_flags';
|
|
|
|
private readonly Dumper $dumper;
|
|
private readonly Parser $parser;
|
|
private array $defaultContext = [
|
|
self::YAML_INLINE => 0,
|
|
self::YAML_INDENT => 0,
|
|
self::YAML_FLAGS => 0,
|
|
];
|
|
|
|
public function __construct(?Dumper $dumper = null, ?Parser $parser = null, array $defaultContext = [])
|
|
{
|
|
if (!class_exists(Dumper::class)) {
|
|
throw new RuntimeException('The YamlEncoder class requires the "Yaml" component. Try running "composer require symfony/yaml".');
|
|
}
|
|
|
|
if (!$dumper) {
|
|
$dumper = \array_key_exists(self::YAML_INDENTATION, $defaultContext) ? new Dumper($defaultContext[self::YAML_INDENTATION]) : new Dumper();
|
|
}
|
|
$this->dumper = $dumper;
|
|
$this->parser = $parser ?? new Parser();
|
|
unset($defaultContext[self::YAML_INDENTATION]);
|
|
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
|
|
}
|
|
|
|
public function encode(mixed $data, string $format, array $context = []): string
|
|
{
|
|
$context = array_merge($this->defaultContext, $context);
|
|
|
|
if ($context[self::PRESERVE_EMPTY_OBJECTS] ?? false) {
|
|
$context[self::YAML_FLAGS] |= Yaml::DUMP_OBJECT_AS_MAP;
|
|
}
|
|
|
|
return $this->dumper->dump($data, $context[self::YAML_INLINE], $context[self::YAML_INDENT], $context[self::YAML_FLAGS]);
|
|
}
|
|
|
|
public function supportsEncoding(string $format): bool
|
|
{
|
|
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
|
|
}
|
|
|
|
public function decode(string $data, string $format, array $context = []): mixed
|
|
{
|
|
$context = array_merge($this->defaultContext, $context);
|
|
|
|
try {
|
|
return $this->parser->parse($data, $context[self::YAML_FLAGS]);
|
|
} catch (ParseException $e) {
|
|
throw new NotEncodableValueException($e->getMessage(), $e->getCode(), $e);
|
|
}
|
|
}
|
|
|
|
public function supportsDecoding(string $format): bool
|
|
{
|
|
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
|
|
}
|
|
}
|