Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
AddSecondLevelCache
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 postRun
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2namespace Apie\DoctrineEntityConverter\CodeGenerators;
3
4use Apie\StorageMetadataBuilder\Interfaces\PostRunGeneratedCodeContextInterface;
5use Apie\StorageMetadataBuilder\Interfaces\RootObjectInterface;
6use Apie\StorageMetadataBuilder\Mediators\GeneratedCodeContext;
7use Doctrine\ORM\Mapping\Cache;
8use Nette\PhpGenerator\ClassType;
9
10class AddSecondLevelCache implements PostRunGeneratedCodeContextInterface
11{
12    public function postRun(GeneratedCodeContext $generatedCodeContext): void
13    {
14        $rootObjects = $generatedCodeContext->generatedCode->generatedCodeHashmap->getObjectsWithInterface(RootObjectInterface::class);
15        /** @var ClassType $rootObject */
16        foreach ($rootObjects as $rootObject) {
17            $rootObject->addAttribute(Cache::class, ['usage' => 'NONSTRICT_READ_WRITE']);
18        }
19    }
20}