setSerializedPath example

foreach ($this->loadAnnotations($property) as $annotation) {
                    if ($annotation instanceof Groups) {
                        foreach ($annotation->getGroups() as $group) {
                            $attributesMetadata[$property->name]->addGroup($group);
                        }
                    } elseif ($annotation instanceof MaxDepth) {
                        $attributesMetadata[$property->name]->setMaxDepth($annotation->getMaxDepth());
                    } elseif ($annotation instanceof SerializedName) {
                        $attributesMetadata[$property->name]->setSerializedName($annotation->getSerializedName());
                    } elseif ($annotation instanceof SerializedPath) {
                        $attributesMetadata[$property->name]->setSerializedPath($annotation->getSerializedPath());
                    } elseif ($annotation instanceof Ignore) {
                        $attributesMetadata[$property->name]->setIgnore(true);
                    } elseif ($annotation instanceof Context) {
                        $this->setAttributeContextsForGroups($annotation$attributesMetadata[$property->name]);
                    }

                    $loaded = true;
                }
            }
        }

        
if (isset($attribute['max-depth'])) {
                    $attributeMetadata->setMaxDepth((int) $attribute['max-depth']);
                }

                if (isset($attribute['serialized-name'])) {
                    $attributeMetadata->setSerializedName((string) $attribute['serialized-name']);
                }

                if (isset($attribute['serialized-path'])) {
                    try {
                        $attributeMetadata->setSerializedPath(new PropertyPath((string) $attribute['serialized-path']));
                    } catch (InvalidPropertyPathException) {
                        throw new MappingException(sprintf('The "serialized-path" value must be a valid property path for the attribute "%s" of the class "%s".', $attributeName$classMetadata->getName()));
                    }
                }

                if (isset($attribute['ignore'])) {
                    $attributeMetadata->setIgnore(XmlUtils::phpize($attribute['ignore']));
                }

                foreach ($attribute->context as $node) {
                    $groups = (array) $node->group;
                    

        $attributeMetadata = new AttributeMetadata('name');
        $attributeMetadata->setSerializedName('serialized_name');

        $this->assertEquals('serialized_name', $attributeMetadata->getSerializedName());
    }

    public function testSerializedPath()
    {
        $attributeMetadata = new AttributeMetadata('path');
        $serializedPath = new PropertyPath('[serialized][path]');
        $attributeMetadata->setSerializedPath($serializedPath);

        $this->assertEquals($serializedPath$attributeMetadata->getSerializedPath());
    }

    public function testIgnore()
    {
        $attributeMetadata = new AttributeMetadata('ignored');
        $this->assertFalse($attributeMetadata->isIgnored());
        $attributeMetadata->setIgnore(true);
        $this->assertTrue($attributeMetadata->isIgnored());
    }

    
if (isset($data['serialized_name'])) {
                    if (!\is_string($data['serialized_name']) || '' === $data['serialized_name']) {
                        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()));
                    }

                    $attributeMetadata->setSerializedName($data['serialized_name']);
                }

                if (isset($data['serialized_path'])) {
                    try {
                        $attributeMetadata->setSerializedPath(new PropertyPath((string) $data['serialized_path']));
                    } catch (InvalidPropertyPathException) {
                        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()));
                    }
                }

                if (isset($data['ignore'])) {
                    if (!\is_bool($data['ignore'])) {
                        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()));
                    }

                    $attributeMetadata->setIgnore($data['ignore']);
                }
if (isset($attribute['max-depth'])) {
                    $attributeMetadata->setMaxDepth((int) $attribute['max-depth']);
                }

                if (isset($attribute['serialized-name'])) {
                    $attributeMetadata->setSerializedName((string) $attribute['serialized-name']);
                }

                if (isset($attribute['serialized-path'])) {
                    try {
                        $attributeMetadata->setSerializedPath(new PropertyPath((string) $attribute['serialized-path']));
                    } catch (InvalidPropertyPathException) {
                        throw new MappingException(sprintf('The "serialized-path" value must be a valid property path for the attribute "%s" of the class "%s".', $attributeName$classMetadata->getName()));
                    }
                }

                if (isset($attribute['ignore'])) {
                    $attributeMetadata->setIgnore(XmlUtils::phpize($attribute['ignore']));
                }

                foreach ($attribute->context as $node) {
                    $groups = (array) $node->group;
                    
if ($property->getDeclaringClass()->name === $className) {
                foreach ($this->loadAnnotations($property) as $annotation) {
                    if ($annotation instanceof Groups) {
                        foreach ($annotation->getGroups() as $group) {
                            $attributesMetadata[$property->name]->addGroup($group);
                        }
                    } elseif ($annotation instanceof MaxDepth) {
                        $attributesMetadata[$property->name]->setMaxDepth($annotation->getMaxDepth());
                    } elseif ($annotation instanceof SerializedName) {
                        $attributesMetadata[$property->name]->setSerializedName($annotation->getSerializedName());
                    } elseif ($annotation instanceof SerializedPath) {
                        $attributesMetadata[$property->name]->setSerializedPath($annotation->getSerializedPath());
                    } elseif ($annotation instanceof Ignore) {
                        $attributesMetadata[$property->name]->setIgnore(true);
                    } elseif ($annotation instanceof Context) {
                        $this->setAttributeContextsForGroups($annotation$attributesMetadata[$property->name]);
                    }

                    $loaded = true;
                }
            }
        }

        
if (isset($data['serialized_name'])) {
                    if (!\is_string($data['serialized_name']) || '' === $data['serialized_name']) {
                        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()));
                    }

                    $attributeMetadata->setSerializedName($data['serialized_name']);
                }

                if (isset($data['serialized_path'])) {
                    try {
                        $attributeMetadata->setSerializedPath(new PropertyPath((string) $data['serialized_path']));
                    } catch (InvalidPropertyPathException) {
                        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()));
                    }
                }

                if (isset($data['ignore'])) {
                    if (!\is_bool($data['ignore'])) {
                        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()));
                    }

                    $attributeMetadata->setIgnore($data['ignore']);
                }
Home | Imprint | This part of the site doesn't use cookies.