4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Serializer\Mapping;
17 * @author Kévin Dunglas <dunglas@gmail.com>
19 class ClassMetadata implements ClassMetadataInterface
24 * @internal This property is public in order to reduce the size of the
25 * class' serialized representation. Do not access it. Use
26 * {@link getName()} instead.
31 * @var AttributeMetadataInterface[]
33 * @internal This property is public in order to reduce the size of the
34 * class' serialized representation. Do not access it. Use
35 * {@link getAttributesMetadata()} instead.
37 public $attributesMetadata = array();
40 * @var \ReflectionClass
45 * Constructs a metadata for the given class.
47 * @param string $class
49 public function __construct($class)
57 public function getName()
65 public function addAttributeMetadata(AttributeMetadataInterface $attributeMetadata)
67 $this->attributesMetadata[$attributeMetadata->getName()] = $attributeMetadata;
73 public function getAttributesMetadata()
75 return $this->attributesMetadata;
81 public function merge(ClassMetadataInterface $classMetadata)
83 foreach ($classMetadata->getAttributesMetadata() as $attributeMetadata) {
84 if (isset($this->attributesMetadata[$attributeMetadata->getName()])) {
85 $this->attributesMetadata[$attributeMetadata->getName()]->merge($attributeMetadata);
87 $this->addAttributeMetadata($attributeMetadata);
95 public function getReflectionClass()
97 if (!$this->reflClass) {
98 $this->reflClass = new \ReflectionClass($this->getName());
101 return $this->reflClass;
105 * Returns the names of the properties that should be serialized.
109 public function __sleep()
113 'attributesMetadata',