8000 feature #22741 [Serializer] Remove deprecated DoctrineCache support (… · symfony/symfony@8514e22 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8514e22

Browse files
committed
feature #22741 [Serializer] Remove deprecated DoctrineCache support (dunglas)
This PR was merged into the 4.0-dev branch. Discussion ---------- [Serializer] Remove deprecated DoctrineCache support | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- be951b7 [Serializer] Remove deprecated DoctrineCache support
2 parents 15b7cdb + be951b7 commit 8514e22

File tree

2 files changed

+1
-52
lines changed

2 files changed

+1
-52
lines changed

src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Serializer\Mapping\Factory;
1313

14-
use Doctrine\Common\Cache\Cache;
1514
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
1615
use Symfony\Component\Serializer\Mapping\ClassMetadata;
1716
use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface;
@@ -30,28 +29,17 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
3029
*/
3130
private $loader;
3231

33-
/**
34-
* @var Cache
35-
*/
36-
private $cache;
37-
3832
/**
3933
* @var array
4034
*/
4135
private $loadedClasses;
4236

4337
/**
4438
* @param LoaderInterface $loader
45-
* @param Cache|null $cache
4639
*/
47-
public function __construct(LoaderInterface $loader, Cache $cache = null)
40+
public function __construct(LoaderInterface $loader)
4841
{
4942
$this->loader = $loader;
50-
$this->cache = $cache;
51-
52-
if (null !== $cache) {
53-
@trigger_error(sprintf('Passing a Doctrine Cache instance as 2nd parameter of the "%s" constructor is deprecated since version 3.1. This parameter will be removed in Symfony 4.0. Use the "%s" class instead.', __CLASS__, CacheClassMetadataFactory::class), E_USER_DEPRECATED);
54-
}
5543
}
5644

5745
/**
@@ -65,10 +53,6 @@ public function getMetadataFor($value)
6553
return $this->loadedClasses[$class];
6654
}
6755

68-
if ($this->cache && ($this->loadedClasses[$class] = $this->cache->fetch($class))) {
69-
return $this->loadedClasses[$class];
70-
}
71-
7256
$classMetadata = new ClassMetadata($class);
7357
$this->loader->loadClassMetadata($classMetadata);
7458

@@ -84,10 +68,6 @@ public function getMetadataFor($value)
8468
$classMetadata->merge($this->getMetadataFor($interface->name));
8569
}
8670

87-
if ($this->cache) {
88-
$this->cache->save($class, $classMetadata);
89-
}
90-
9171
return $this->loadedClasses[$class] = $classMetadata;
9272
}
9373

src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,4 @@ public function testHasMetadataFor()
4545
$this->assertTrue($factory->hasMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummyInterface'));
4646
$this->assertFalse($factory->hasMetadataFor('Dunglas\Entity'));
4747
}
48-
49-
/**
50-
* @group legacy
51-
*/
52-
public function testCacheExists()
53-
{
54-
$cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
55-
$cache
56-
->expects($this->once())
57-
->method('fetch')
58-
->will($this->returnValue('foo'))
59-
;
60-
61-
$factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()), $cache);
62-
$this->assertEquals('foo', $factory->getMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy'));
63-
}
64-
65-
/**
66-
* @group legacy
67-
*/
68-
public function testCacheNotExists()
69-
{
70-
$cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
71-
$cache->method('fetch')->will($this->returnValue(false));
72-
$cache->method('save');
73-
74-
$factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()), $cache);
75-
$metadata = $factory->getMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\GroupDummy');
76-
77-
$this->assertEquals(TestClassMetadataFactory::createClassMetadata(true, true), $metadata);
78-
}
7948
}

0 commit comments

Comments
 (0)
0