Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 544e466

Browse filesBrowse files
committed
Added MetadataLoader to PropertyAccess configuration registration
1 parent f6dd635 commit 544e466
Copy full SHA for 544e466

File tree

8 files changed

+71
-5
lines changed
Filter options

8 files changed

+71
-5
lines changed

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ CHANGELOG
2727
name as value, using it makes the command lazy
2828
* Added `cache:pool:prune` command to allow manual stale cache item pruning of supported PSR-6 and PSR-16 cache pool
2929
implementations
30+
* Added custom property accessors support
3031
* Deprecated `Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader`, use
3132
`Symfony\Component\Translation\Reader\TranslationReader` instead
3233
* Deprecated `translation.loader` service, use `translation.reader` instead

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,16 @@ private function addPropertyAccessSection(ArrayNodeDefinition $rootNode)
786786
->children()
787787
->booleanNode('magic_call')->defaultFalse()->end()
788788
->booleanNode('throw_exception_on_invalid_index')->defaultFalse()->end()
789-
->end()
789+
->booleanNode('enable_annotations')->defaultFalse()->end()
790+
->arrayNode('mapping')
791+
->addDefaultsIfNotSet()
792+
->fixXmlConfig('path')
793+
->children()
794+
->arrayNode('paths')
795+
->prototype('scalar')->end()
796+
->end()
797+
->end()
798+
->end()
790799
->end()
791800
->end()
792801
;

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+31-4Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,17 +1398,17 @@ private function registerComponentMapping(ContainerBuilder $container, $fileReco
13981398
$dirname = $bundle['path'];
13991399

14001400
if (
1401-
$container->fileExists($file = $dirname . '/Resources/config/'.$component.'.yaml', false) ||
1402-
$container->fileExists($file = $dirname . '/Resources/config/'.$component.'.yml', false)
1401+
$container->fileExists($file = $dirname.'/Resources/config/'.$component.'.yaml', false) ||
1402+
$container->fileExists($file = $dirname.'/Resources/config/'.$component.'.yml', false)
14031403
) {
14041404
$fileRecorder('yml', $file);
14051405
}
14061406

1407-
if ($container->fileExists($file = $dirname . '/Resources/config/'.$component.'.xml', false)) {
1407+
if ($container->fileExists($file = $dirname.'/Resources/config/'.$component.'.xml', false)) {
14081408
$fileRecorder('xml', $file);
14091409
}
14101410

1411-
if ($container->fileExists($dir = $dirname . '/Resources/config/'.$component, '/^$/')) {
1411+
if ($container->fileExists($dir = $dirname.'/Resources/config/'.$component, '/^$/')) {
14121412
$this->registerMappingFilesFromDir($dir, $fileRecorder);
14131413
}
14141414
}
@@ -1501,6 +1501,33 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
15011501

15021502
private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container)
15031503
{
1504+
$loaders = array();
1505+
$fileRecorder = function ($extension, $path) use (&$loaders) {
1506+
$definition = new Definition(in_array($extension, array('yaml', 'yml')) ? 'Symfony\Component\PropertyAccess\Mapping\Loader\YamlFileLoader' : 'Symfony\Component\PropertyAccess\Mapping\Loader\XmlFileLoader', array($path));
1507+
$definition->setPublic(false);
1508+
$loaders[] = $definition;
1509+
};
1510+
1511+
if (isset($config['enable_annotations']) && $config['enable_annotations']) {
1512+
if (!$this->annotationsConfigEnabled) {
1513+
throw new \LogicException('"enable_annotations" on property access cannot be set as Annotations support is disabled.');
1514+
}
1515+
$annotationLoader = new Definition(
1516+
'Symfony\Component\PropertyAccess\Mapping\Loader\AnnotationLoader',
1517+
array(new Reference('annotation_reader'))
1518+
);
1519+
$annotationLoader->setPublic(false);
1520+
$loaders[] = $annotationLoader;
1521+
}
1522+
1523+
$this->registerComponentMapping($container, $fileRecorder, 'property_accessor');
1524+
1525+
$this->registerMappingFilesFromConfig($container, $config, $fileRecorder);
1526+
1527+
$chainLoader = $container->getDefinition('property_access.mapping.chain_loader');
1528+
1529+
$chainLoader->replaceArgument(0, $loaders);
1530+
15041531
$container
15051532
->getDefinition('property_accessor')
15061533
->replaceArgument(0, $config['magic_call'])

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,21 @@
77
<services>
88
<defaults public="false" />
99

10+
<!-- Loader -->
11+
<service id="property_access.mapping.chain_loader" class="Symfony\Component\PropertyAccess\Mapping\Loader\LoaderChain">
12+
<argument type="collection" />
13+
</service>
14+
15+
<!-- Class Metadata Factory -->
16+
<service id="property_access.mapping.class_metadata_factory" class="Symfony\Component\PropertyAccess\Mapping\Factory\LazyLoadingMetadataFactory">
17+
<argument type="service" id="property_access.mapping.chain_loader" />
18+
</service>
19+
1020
<service id="property_accessor" class="Symfony\Component\PropertyAccess\PropertyAccessor">
1121
<argument /> <!-- magicCall, set by the extension -->
1222
<argument /> <!-- throwExceptionOnInvalidIndex, set by the extension -->
1323
<argument type="service" id="cache.property_access" on-invalid="ignore" />
24+
<argument type="service" id="property_access.mapping.class_metadata_factory" on-invalid="ignore" />
1425
</service>
1526
<service id="Symfony\Component\PropertyAccess\PropertyAccessorInterface" alias="property_accessor" />
1627
</services>

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ protected static function getBundleDefaultConfig()
283283
'property_access' => array(
284284
'magic_call' => false,
285285
'throw_exception_on_invalid_index' => false,
286+
'enable_annotations' => false,
287+
'mapping' => array(
288+
'paths' => array(),
289+
),
286290
),
287291
'property_info' => array(
288292
'enabled' => false,

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
'debug' => true,
6565
'file_cache_dir' => '%kernel.cache_dir%/annotations',
6666
),
67+
'property_access' => array(
68+
'magic_call' => false,
69+
'throw_exception_on_invalid_index' => false,
70+
'enable_annotations' => true,
71+
),
6772
'serializer' => array(
6873
'enabled' => true,
6974
'enable_annotations' => true,

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
'property_access' => array(
55
'magic_call' => true,
66
'throw_exception_on_invalid_index' => true,
7+
'enable_annotations' => true,
78
),
89
));

‎src/Symfony/Bundle/FrameworkBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/composer.json
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
"homepage": "https://symfony.com/contributors"
1616
}
1717
],
18+
"repositories": [
19+
{
20+
"type": "git",
21+
"url": "https://github.com/lrlopez/property-access"
22+
}
23+
],
1824
"require": {
1925
"php": "^5.5.9|>=7.0.8",
2026
"ext-xml": "*",
@@ -35,6 +41,7 @@
3541
"fig/link-util": "^1.0",
3642
"symfony/asset": "~3.3|~4.0",
3743
"symfony/browser-kit": "~2.8|~3.0|~4.0",
44+
"symfony/cache": "~3.4|~4.0",
3845
"symfony/console": "~3.4|~4.0",
3946
"symfony/css-selector": "~2.8|~3.0|~4.0",
4047
"symfony/dom-crawler": "~2.8|~3.0|~4.0",
@@ -43,6 +50,7 @@
4350
"symfony/form": "~3.4|~4.0",
4451
"symfony/expression-language": "~2.8|~3.0|~4.0",
4552
"symfony/process": "~2.8|~3.0|~4.0",
53+
"symfony/property-access": "dev-master",
4654
"symfony/security-core": "~3.2|~4.0",
4755
"symfony/security-csrf": "~2.8|~3.0|~4.0",
4856
"symfony/serializer": "~3.3|~4.0",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.