Skip to content

Commit

Permalink
doctrine/cache is replaced in favor of symfony/cache (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcoppens authored Feb 27, 2024
1 parent f22e325 commit fe24dcb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"ext-libxml": "*",
"ext-dom": "*",
"doctrine/annotations": "~1.13.0",
"doctrine/cache": "~1.0",
"php": ">=7.2",
"symfony/framework-bundle": "~5.4",
"symfony/translation": "~5.4"
"symfony/translation": "~5.4",
"symfony/cache": "~5.4"
},
"require-dev": {
"doctrine/common": "~3.0",
Expand Down
14 changes: 8 additions & 6 deletions src/Service/Extractor/AnnotationExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace BowlOfSoup\NormalizerBundle\Service\Extractor;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\PsrCachedReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\FilesystemCache;
use Doctrine\Persistence\Proxy;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

class AnnotationExtractor
{
Expand All @@ -18,24 +18,26 @@ class AnnotationExtractor

/** @var array */
private $annotationCache = [];

/** @var string */
public const CACHE_NS = 'bos_annotations';

/**
* @codeCoverageIgnore
*/
public function __construct(string $cacheDir = null, bool $debugMode = false)
{
if (null !== $cacheDir) {
$cacheDir .= '/annotations';
$this->createDirectory($cacheDir);

if ($this->directoryExits($cacheDir)) {
$this->annotationReader = new CachedReader(new AnnotationReader(), new FilesystemCache($cacheDir), $debugMode);
$this->annotationReader = new PsrCachedReader(new AnnotationReader(), new FilesystemAdapter(self::CACHE_NS, 0, $cacheDir), $debugMode);

return;
}
}

$this->annotationReader = new CachedReader(new AnnotationReader(), new ArrayCache(), $debugMode);
$this->annotationReader = new PsrCachedReader(new AnnotationReader(), new ArrayAdapter(), $debugMode);
}

public function setAnnotationReader(Reader $annotationReader): void
Expand Down

0 comments on commit fe24dcb

Please sign in to comment.