/** * {@inheritdoc} */ public function loadClassMetadata(ClassMetadata $metadata) { if (null === $this->classes) { if (!stream_is_local($this->file)) { throw new MappingException(sprintf('This is not a local file "%s".', $this->file)); } if (null === $this->yamlParser) { $this->yamlParser = new Parser(); } $classes = $this->yamlParser->parse(file_get_contents($this->file)); if (empty($classes)) { return false; } // not an array if (!is_array($classes)) { throw new MappingException(sprintf('The file "%s" must contain a YAML array.', $this->file)); } $this->classes = $classes; } if (isset($this->classes[$metadata->getClassName()])) { $yaml = $this->classes[$metadata->getClassName()]; if (isset($yaml['attributes']) && is_array($yaml['attributes'])) { foreach ($yaml['attributes'] as $attribute => $data) { if (isset($data['groups'])) { foreach ($data['groups'] as $group) { $metadata->addAttributeGroup($attribute, $group); } } } } return true; } return false; }
/** * {@inheritdoc} */ public function loadClassMetadata(ClassMetadata $metadata) { if (null === $this->classes) { $this->classes = array(); $xml = $this->parseFile($this->file); foreach ($xml->class as $class) { $this->classes[(string) $class['name']] = $class; } } if (isset($this->classes[$metadata->getClassName()])) { $xml = $this->classes[$metadata->getClassName()]; foreach ($xml->attribute as $attribute) { foreach ($attribute->group as $group) { $metadata->addAttributeGroup((string) $attribute['name'], (string) $group); } } return true; } return false; }