From c526dcc88130ba0361284acfd4407c4439d0c398 Mon Sep 17 00:00:00 2001 From: Kharhamel Date: Wed, 5 Feb 2020 16:17:48 +0100 Subject: [PATCH] implemented a cache and a cache clearer in tdbm bundle --- .gitattributes | 6 ++++++ Resources/config/container/tdbm.xml | 11 +++++++++++ Tests/Fixtures/config/services.yaml | 2 +- Tests/FunctionalTest.php | 1 - Tests/TdbmTestingKernel.php | 2 -- Utils/DoctrineCacheClearer.php | 28 ++++++++++++++++++++++++++++ composer.json | 5 +++-- 7 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 .gitattributes create mode 100644 Utils/DoctrineCacheClearer.php diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..62b2b70 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +/Tests export-ignore +/phpstan.neon export-ignore +/phpcs.xml.dist export-ignore +/phpcs.xml export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore \ No newline at end of file diff --git a/Resources/config/container/tdbm.xml b/Resources/config/container/tdbm.xml index 36e158c..b78ca02 100644 --- a/Resources/config/container/tdbm.xml +++ b/Resources/config/container/tdbm.xml @@ -15,8 +15,19 @@ + + + %kernel.project_dir%/var/cache/tdbm + + + + + + + + diff --git a/Tests/Fixtures/config/services.yaml b/Tests/Fixtures/config/services.yaml index d0fcf25..1f84f20 100644 --- a/Tests/Fixtures/config/services.yaml +++ b/Tests/Fixtures/config/services.yaml @@ -13,7 +13,7 @@ services: # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name - TheCodingMachine\Graphqlite\Bundle\Tests\Fixtures\: + TheCodingMachine\TDBM\Bundle\Tests\Fixtures\: resource: '../*' exclude: '../{Entities}' diff --git a/Tests/FunctionalTest.php b/Tests/FunctionalTest.php index 7b08315..f6e1506 100644 --- a/Tests/FunctionalTest.php +++ b/Tests/FunctionalTest.php @@ -4,7 +4,6 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; -use TheCodingMachine\GraphQLite\Schema; use TheCodingMachine\TDBM\TDBMService; class FunctionalTest extends TestCase diff --git a/Tests/TdbmTestingKernel.php b/Tests/TdbmTestingKernel.php index c63f6ad..77ab4f0 100644 --- a/Tests/TdbmTestingKernel.php +++ b/Tests/TdbmTestingKernel.php @@ -10,9 +10,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Routing\RouteCollectionBuilder; -use TheCodingMachine\Graphqlite\Bundle\GraphqliteBundle; use TheCodingMachine\TDBM\Bundle\TdbmBundle; -use TheCodingMachine\TDBM\Bundle\TdbmGraphqlBundle; class TdbmTestingKernel extends Kernel { diff --git a/Utils/DoctrineCacheClearer.php b/Utils/DoctrineCacheClearer.php new file mode 100644 index 0000000..fe4d64a --- /dev/null +++ b/Utils/DoctrineCacheClearer.php @@ -0,0 +1,28 @@ +cache = $cache; + } + + /** + * Clears any caches necessary. + */ + public function clear($cacheDir) + { + $this->cache->flushAll(); + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index 84e43da..42b5ba5 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ "php" : ">=7.1", "thecodingmachine/tdbm" : "~5.1.0", "doctrine/doctrine-bundle": "^1.9 || ^2", - "doctrine/orm": "^1 || ^2" + "doctrine/orm": "^1 || ^2", + "symfony/http-kernel": "^4.1.9 || ^5" }, "require-dev": { "roave/security-advisories": "dev-master", @@ -34,7 +35,7 @@ "phpstan/phpstan-shim": "^0.11.4" }, "scripts": { - "phpstan": "phpstan analyse TdbmBundle.php DependencyInjection/ Resources/ -c phpstan.neon --level=7 --no-progress" + "phpstan": "phpstan analyse TdbmBundle.php DependencyInjection/ Resources/ Utils/ -c phpstan.neon --level=7 --no-progress" }, "autoload" : { "psr-4" : {