Skip to content

Commit

Permalink
Merge pull request #6 from Kharhamel/fix/cache
Browse files Browse the repository at this point in the history
implemented a cache and a cache clearer in tdbm bundle
  • Loading branch information
moufmouf authored Feb 5, 2020
2 parents e4f6c91 + c526dcc commit 383f5f2
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions Resources/config/container/tdbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@
<argument key="$codeGeneratorListeners" type="collection">
<argument type="service" id="TheCodingMachine\TDBM\Bundle\Utils\SymfonyCodeGeneratorListener"/>
</argument>
<argument key="$cache" type="service" id="tdbm.cache"></argument>
</service>

<service id="tdbm.cache" class="Doctrine\Common\Cache\FilesystemCache">
<argument>%kernel.project_dir%/var/cache/tdbm</argument>
</service>


<service id="tdbm.cacheclearer" class="TheCodingMachine\TDBM\Bundle\Utils\DoctrineCacheClearer">
<argument type="service" id="tdbm.cache" />
<tag name="kernel.cache_clearer"/>
</service>

<service id="TheCodingMachine\TDBM\ConfigurationInterface" alias="TheCodingMachine\TDBM\Configuration">
</service>

Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}'

Expand Down
1 change: 0 additions & 1 deletion Tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions Tests/TdbmTestingKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
28 changes: 28 additions & 0 deletions Utils/DoctrineCacheClearer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php


namespace TheCodingMachine\TDBM\Bundle\Utils;

use Doctrine\Common\Cache\FlushableCache;
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;

class DoctrineCacheClearer implements CacheClearerInterface
{
/**
* @var FlushableCache
*/
private $cache;

public function __construct(FlushableCache $cache)
{
$this->cache = $cache;
}

/**
* Clears any caches necessary.
*/
public function clear($cacheDir)
{
$this->cache->flushAll();
}
}
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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" : {
Expand Down

0 comments on commit 383f5f2

Please sign in to comment.