class YamlFileLoader in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/routing/Loader/YamlFileLoader.php \Symfony\Component\Routing\Loader\YamlFileLoader
- 8 vendor/symfony/translation/Loader/YamlFileLoader.php \Symfony\Component\Translation\Loader\YamlFileLoader
- 8 vendor/symfony/dependency-injection/Loader/YamlFileLoader.php \Symfony\Component\DependencyInjection\Loader\YamlFileLoader
- 8 vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php \Symfony\Component\Validator\Mapping\Loader\YamlFileLoader
- 8 vendor/symfony/serializer/Mapping/Loader/YamlFileLoader.php \Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader
- 8 core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader
Same name and namespace in other branches
- 8.0 vendor/symfony/serializer/Mapping/Loader/YamlFileLoader.php \Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader
YAML File Loader.
@author Kévin Dunglas <dunglas@gmail.com>
Hierarchy
- class \Symfony\Component\Serializer\Mapping\Loader\FileLoader implements LoaderInterface
- class \Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader
Expanded class hierarchy of YamlFileLoader
1 file declares its use of YamlFileLoader
- YamlFileLoaderTest.php in vendor/
symfony/ serializer/ Tests/ Mapping/ Loader/ YamlFileLoaderTest.php
1 string reference to 'YamlFileLoader'
- TranslatorTest::getTransFileTests in vendor/
symfony/ translation/ Tests/ TranslatorTest.php
File
- vendor/
symfony/ serializer/ Mapping/ Loader/ YamlFileLoader.php, line 24
Namespace
Symfony\Component\Serializer\Mapping\LoaderView source
class YamlFileLoader extends FileLoader {
private $yamlParser;
/**
* An array of YAML class descriptions.
*
* @var array
*/
private $classes = null;
/**
* {@inheritdoc}
*/
public function loadClassMetadata(ClassMetadataInterface $classMetadata) {
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[$classMetadata
->getName()])) {
$yaml = $this->classes[$classMetadata
->getName()];
if (isset($yaml['attributes']) && is_array($yaml['attributes'])) {
$attributesMetadata = $classMetadata
->getAttributesMetadata();
foreach ($yaml['attributes'] as $attribute => $data) {
if (isset($attributesMetadata[$attribute])) {
$attributeMetadata = $attributesMetadata[$attribute];
}
else {
$attributeMetadata = new AttributeMetadata($attribute);
$classMetadata
->addAttributeMetadata($attributeMetadata);
}
if (isset($data['groups'])) {
foreach ($data['groups'] as $group) {
$attributeMetadata
->addGroup($group);
}
}
}
}
return true;
}
return false;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FileLoader:: |
protected | property | ||
FileLoader:: |
public | function | Constructor. | |
YamlFileLoader:: |
private | property | An array of YAML class descriptions. | |
YamlFileLoader:: |
private | property | ||
YamlFileLoader:: |
public | function |
Load class metadata. Overrides LoaderInterface:: |