Drupal investigation

AttributeMetadata.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Serializer\Mapping;
  11. /**
  12. * {@inheritdoc}
  13. *
  14. * @author Kévin Dunglas <dunglas@gmail.com>
  15. */
  16. class AttributeMetadata implements AttributeMetadataInterface
  17. {
  18. /**
  19. * @var string
  20. *
  21. * @internal This property is public in order to reduce the size of the
  22. * class' serialized representation. Do not access it. Use
  23. * {@link getName()} instead.
  24. */
  25. public $name;
  26. /**
  27. * @var array
  28. *
  29. * @internal This property is public in order to reduce the size of the
  30. * class' serialized representation. Do not access it. Use
  31. * {@link getGroups()} instead.
  32. */
  33. public $groups = array();
  34. /**
  35. * Constructs a metadata for the given attribute.
  36. *
  37. * @param string $name
  38. */
  39. public function __construct($name)
  40. {
  41. $this->name = $name;
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function getName()
  47. {
  48. return $this->name;
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function addGroup($group)
  54. {
  55. if (!in_array($group, $this->groups)) {
  56. $this->groups[] = $group;
  57. }
  58. }
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public function getGroups()
  63. {
  64. return $this->groups;
  65. }
  66. /**
  67. * {@inheritdoc}
  68. */
  69. public function merge(AttributeMetadataInterface $attributeMetadata)
  70. {
  71. foreach ($attributeMetadata->getGroups() as $group) {
  72. $this->addGroup($group);
  73. }
  74. }
  75. /**
  76. * Returns the names of the properties that should be serialized.
  77. *
  78. * @return string[]
  79. */
  80. public function __sleep()
  81. {
  82. return array('name', 'groups');
  83. }
  84. }