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 42ccf65

Browse filesBrowse files
committed
[FrameworkBundle] PropertyAccess cache support
1 parent d925c6a commit 42ccf65
Copy full SHA for 42ccf65

File tree

4 files changed

+28
-5
lines changed
Filter options

4 files changed

+28
-5
lines changed

‎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>

‎src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/PropertyAccessorBuilder.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,21 @@ public function isExceptionOnInvalidIndexEnabled()
105105
}
106106

107107
/**
108-
* Uses a cache system.
108+
* Sets a cache system.
109109
*
110110
* @param Cache|null $cache
111111
*
112112
* @return PropertyAccessorBuilder The builder object
113113
*/
114-
public function useCache(Cache $cache = null)
114+
public function setCache(Cache $cache = null)
115115
{
116116
$this->cache = $cache;
117117

118118
return $this;
119119
}
120120

121121
/**
122-
* Gets the cache system.
122+
* Gets the used cache system.
123123
*
124124
* @return Cache|null
125125
*/

‎src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorBuilderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorBuilderTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testGetPropertyAccessor()
5757
public function testUseCache()
5858
{
5959
$cache = new ArrayCache();
60-
$this->builder->useCache($cache);
60+
$this->builder->setCache($cache);
6161
$this->assertEquals($cache, $this->builder->getCache());
6262
$this->assertInstanceOf('Symfony\Component\PropertyAccess\PropertyAccessor', $this->builder->getPropertyAccessor());
6363
}

0 commit comments

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