Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/serializer/Mapping/Loader/YamlFileLoader.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
28 /** | 28 /** |
29 * An array of YAML class descriptions. | 29 * An array of YAML class descriptions. |
30 * | 30 * |
31 * @var array | 31 * @var array |
32 */ | 32 */ |
33 private $classes = null; | 33 private $classes; |
34 | 34 |
35 /** | 35 /** |
36 * {@inheritdoc} | 36 * {@inheritdoc} |
37 */ | 37 */ |
38 public function loadClassMetadata(ClassMetadataInterface $classMetadata) | 38 public function loadClassMetadata(ClassMetadataInterface $classMetadata) |
49 return false; | 49 return false; |
50 } | 50 } |
51 | 51 |
52 $yaml = $this->classes[$classMetadata->getName()]; | 52 $yaml = $this->classes[$classMetadata->getName()]; |
53 | 53 |
54 if (isset($yaml['attributes']) && is_array($yaml['attributes'])) { | 54 if (isset($yaml['attributes']) && \is_array($yaml['attributes'])) { |
55 $attributesMetadata = $classMetadata->getAttributesMetadata(); | 55 $attributesMetadata = $classMetadata->getAttributesMetadata(); |
56 | 56 |
57 foreach ($yaml['attributes'] as $attribute => $data) { | 57 foreach ($yaml['attributes'] as $attribute => $data) { |
58 if (isset($attributesMetadata[$attribute])) { | 58 if (isset($attributesMetadata[$attribute])) { |
59 $attributeMetadata = $attributesMetadata[$attribute]; | 59 $attributeMetadata = $attributesMetadata[$attribute]; |
61 $attributeMetadata = new AttributeMetadata($attribute); | 61 $attributeMetadata = new AttributeMetadata($attribute); |
62 $classMetadata->addAttributeMetadata($attributeMetadata); | 62 $classMetadata->addAttributeMetadata($attributeMetadata); |
63 } | 63 } |
64 | 64 |
65 if (isset($data['groups'])) { | 65 if (isset($data['groups'])) { |
66 if (!is_array($data['groups'])) { | 66 if (!\is_array($data['groups'])) { |
67 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())); | 67 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())); |
68 } | 68 } |
69 | 69 |
70 foreach ($data['groups'] as $group) { | 70 foreach ($data['groups'] as $group) { |
71 if (!is_string($group)) { | 71 if (!\is_string($group)) { |
72 throw new MappingException(sprintf('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName())); | 72 throw new MappingException(sprintf('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName())); |
73 } | 73 } |
74 | 74 |
75 $attributeMetadata->addGroup($group); | 75 $attributeMetadata->addGroup($group); |
76 } | 76 } |
111 | 111 |
112 if (null === $this->yamlParser) { | 112 if (null === $this->yamlParser) { |
113 $this->yamlParser = new Parser(); | 113 $this->yamlParser = new Parser(); |
114 } | 114 } |
115 | 115 |
116 $classes = $this->yamlParser->parse(file_get_contents($this->file)); | 116 $classes = $this->yamlParser->parseFile($this->file); |
117 | 117 |
118 if (empty($classes)) { | 118 if (empty($classes)) { |
119 return array(); | 119 return array(); |
120 } | 120 } |
121 | 121 |
122 if (!is_array($classes)) { | 122 if (!\is_array($classes)) { |
123 throw new MappingException(sprintf('The file "%s" must contain a YAML array.', $this->file)); | 123 throw new MappingException(sprintf('The file "%s" must contain a YAML array.', $this->file)); |
124 } | 124 } |
125 | 125 |
126 return $classes; | 126 return $classes; |
127 } | 127 } |