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 7108cc1

Browse filesBrowse files
committed
[FrameworkBundle] PropertyAccess cache support
1 parent 5295a0c commit 7108cc1
Copy full SHA for 7108cc1

File tree

3 files changed

+25
-1
lines changed
Filter options

3 files changed

+25
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ private function addPropertyAccessSection(ArrayNodeDefinition $rootNode)
504504
->children()
505505
->booleanNode('magic_call')->defaultFalse()->end()
506506
->booleanNode('throw_exception_on_invalid_index')->defaultFalse()->end()
507+
->scalarNode('cache')->end()
507508
->end()
508509
->end()
509510
->end()

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,22 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
838838

839839
private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container)
840840
{
841-
$container
841+
$definition = $container
842842
->getDefinition('property_accessor')
843843
->replaceArgument(0, $config['magic_call'])
844844
->replaceArgument(1, $config['throw_exception_on_invalid_index'])
845845
;
846+
847+
if (isset($config['cache']) && $config['cache']) {
848+
$container->setParameter(
849+
'property_accessor.cache.prefix',
850+
'property_accessor_'.hash('sha256', $container->getParameter('kernel.root_dir'))
851+
);
852+
853+
$definition->replaceArgument(
854+
2, new Reference($config['cache'])
855+
);
856+
}
846857
}
847858

848859
/**

‎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
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,22 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
66

7+
<parameters>
8+
<parameter key="property_accessor.cache.prefix" />
9+
</parameters>
10+
711
<services>
812
<service id="property_accessor" class="Symfony\Component\PropertyAccess\PropertyAccessor" >
913
<argument /> <!-- magicCall, set by the extension -->
1014
<argument /> <!-- throwExceptionOnInvalidIndex, set by the extension -->
15+
<argument /> <!-- cache, set by the extension -->
16+
</service>
17+
18+
<!-- Cache -->
19+
<service id="property_accessor.cache.apc" class="Doctrine\Common\Cache\ApcCache" public="false">
20+
<call method="setNamespace">
21+
<argument>%property_accessor.cache.prefix%</argument>
22+
</call>
1123
</service>
1224
</services>
1325
</container>

0 commit comments

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