api/symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.yaml
2024-09-26 02:03:21 -07:00

101 lines
6.4 KiB
YAML

name: YamlFileLoader
class_comment: "# * YAML File Loader.\n# *\n# * @author K\xE9vin Dunglas <dunglas@gmail.com>"
dependencies:
- name: InvalidPropertyPathException
type: class
source: Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException
- name: PropertyPath
type: class
source: Symfony\Component\PropertyAccess\PropertyPath
- name: MappingException
type: class
source: Symfony\Component\Serializer\Exception\MappingException
- name: AttributeMetadata
type: class
source: Symfony\Component\Serializer\Mapping\AttributeMetadata
- name: ClassDiscriminatorMapping
type: class
source: Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping
- name: ClassMetadataInterface
type: class
source: Symfony\Component\Serializer\Mapping\ClassMetadataInterface
- name: Parser
type: class
source: Symfony\Component\Yaml\Parser
- name: Yaml
type: class
source: Symfony\Component\Yaml\Yaml
properties: []
methods:
- name: getMappedClasses
visibility: public
parameters: []
comment: "# * YAML File Loader.\n# *\n# * @author K\xE9vin Dunglas <dunglas@gmail.com>\n\
# */\n# class YamlFileLoader extends FileLoader\n# {\n# private ?Parser $yamlParser\
\ = null;\n# \n# /**\n# * An array of YAML class descriptions.\n# */\n# private\
\ ?array $classes = null;\n# \n# public function loadClassMetadata(ClassMetadataInterface\
\ $classMetadata): bool\n# {\n# if (!$this->classes ??= $this->getClassesFromYaml())\
\ {\n# return false;\n# }\n# \n# if (!isset($this->classes[$classMetadata->getName()]))\
\ {\n# return false;\n# }\n# \n# $yaml = $this->classes[$classMetadata->getName()];\n\
# \n# if (isset($yaml['attributes']) && \\is_array($yaml['attributes'])) {\n#\
\ $attributesMetadata = $classMetadata->getAttributesMetadata();\n# \n# foreach\
\ ($yaml['attributes'] as $attribute => $data) {\n# if (isset($attributesMetadata[$attribute]))\
\ {\n# $attributeMetadata = $attributesMetadata[$attribute];\n# } else {\n# $attributeMetadata\
\ = new AttributeMetadata($attribute);\n# $classMetadata->addAttributeMetadata($attributeMetadata);\n\
# }\n# \n# if (isset($data['groups'])) {\n# if (!\\is_array($data['groups']))\
\ {\n# throw new MappingException(\\sprintf('The \"groups\" key must be an array\
\ of strings in \"%s\" for the attribute \"%s\" of the class \"%s\".', $this->file,\
\ $attribute, $classMetadata->getName()));\n# }\n# \n# foreach ($data['groups']\
\ as $group) {\n# if (!\\is_string($group)) {\n# throw new MappingException(\\\
sprintf('Group names must be strings in \"%s\" for the attribute \"%s\" of the\
\ class \"%s\".', $this->file, $attribute, $classMetadata->getName()));\n# }\n\
# \n# $attributeMetadata->addGroup($group);\n# }\n# }\n# \n# if (isset($data['max_depth']))\
\ {\n# if (!\\is_int($data['max_depth'])) {\n# throw new MappingException(\\sprintf('The\
\ \"max_depth\" value must be an integer in \"%s\" for the attribute \"%s\" of\
\ the class \"%s\".', $this->file, $attribute, $classMetadata->getName()));\n\
# }\n# \n# $attributeMetadata->setMaxDepth($data['max_depth']);\n# }\n# \n# if\
\ (isset($data['serialized_name'])) {\n# if (!\\is_string($data['serialized_name'])\
\ || '' === $data['serialized_name']) {\n# throw new MappingException(\\sprintf('The\
\ \"serialized_name\" value must be a non-empty string in \"%s\" for the attribute\
\ \"%s\" of the class \"%s\".', $this->file, $attribute, $classMetadata->getName()));\n\
# }\n# \n# $attributeMetadata->setSerializedName($data['serialized_name']);\n\
# }\n# \n# if (isset($data['serialized_path'])) {\n# try {\n# $attributeMetadata->setSerializedPath(new\
\ PropertyPath((string) $data['serialized_path']));\n# } catch (InvalidPropertyPathException)\
\ {\n# throw new MappingException(\\sprintf('The \"serialized_path\" value must\
\ be a valid property path in \"%s\" for the attribute \"%s\" of the class \"\
%s\".', $this->file, $attribute, $classMetadata->getName()));\n# }\n# }\n# \n\
# if (isset($data['ignore'])) {\n# if (!\\is_bool($data['ignore'])) {\n# throw\
\ new MappingException(\\sprintf('The \"ignore\" value must be a boolean in \"\
%s\" for the attribute \"%s\" of the class \"%s\".', $this->file, $attribute,\
\ $classMetadata->getName()));\n# }\n# \n# $attributeMetadata->setIgnore($data['ignore']);\n\
# }\n# \n# foreach ($data['contexts'] ?? [] as $line) {\n# $groups = $line['groups']\
\ ?? [];\n# \n# if ($context = $line['context'] ?? false) {\n# $attributeMetadata->setNormalizationContextForGroups($context,\
\ $groups);\n# $attributeMetadata->setDenormalizationContextForGroups($context,\
\ $groups);\n# }\n# \n# if ($context = $line['normalization_context'] ?? false)\
\ {\n# $attributeMetadata->setNormalizationContextForGroups($context, $groups);\n\
# }\n# \n# if ($context = $line['denormalization_context'] ?? false) {\n# $attributeMetadata->setDenormalizationContextForGroups($context,\
\ $groups);\n# }\n# }\n# }\n# }\n# \n# if (isset($yaml['discriminator_map']))\
\ {\n# if (!isset($yaml['discriminator_map']['type_property'])) {\n# throw new\
\ MappingException(\\sprintf('The \"type_property\" key must be set for the discriminator\
\ map of the class \"%s\" in \"%s\".', $classMetadata->getName(), $this->file));\n\
# }\n# \n# if (!isset($yaml['discriminator_map']['mapping'])) {\n# throw new MappingException(\\\
sprintf('The \"mapping\" key must be set for the discriminator map of the class\
\ \"%s\" in \"%s\".', $classMetadata->getName(), $this->file));\n# }\n# \n# $classMetadata->setClassDiscriminatorMapping(new\
\ ClassDiscriminatorMapping(\n# $yaml['discriminator_map']['type_property'],\n\
# $yaml['discriminator_map']['mapping']\n# ));\n# }\n# \n# return true;\n# }\n\
# \n# /**\n# * Return the names of the classes mapped in this file.\n# *\n# *\
\ @return string[]"
- name: getClassesFromYaml
visibility: private
parameters: []
comment: null
traits:
- Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException
- Symfony\Component\PropertyAccess\PropertyPath
- Symfony\Component\Serializer\Exception\MappingException
- Symfony\Component\Serializer\Mapping\AttributeMetadata
- Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping
- Symfony\Component\Serializer\Mapping\ClassMetadataInterface
- Symfony\Component\Yaml\Parser
- Symfony\Component\Yaml\Yaml
interfaces: []