Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasPilar committed Sep 27, 2019
1 parent c12550d commit 96f7d28
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
1 change: 0 additions & 1 deletion docs/en/index.md
Expand Up @@ -24,7 +24,6 @@ This extension can be configured by `doctrine` section. The minimal configuratio

```yml
doctrine:
debug: %debugMode%
connection:
driver: pdo_mysql
host: localhost
Expand Down
23 changes: 15 additions & 8 deletions src/Adapter/Nette/DI/DoctrineExtension.php
Expand Up @@ -58,6 +58,7 @@
use stdClass;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;
use Tracy\IBarPanel;

class DoctrineExtension extends CompilerExtension
{
Expand All @@ -68,10 +69,16 @@ class DoctrineExtension extends CompilerExtension
private $entitySources = [];


/**
* {@inheritdoc}
*/
public function getConfigSchema(): Schema
{
$params = $this->getContainerBuilder()->parameters;
$tempDir = $params['tempDir'] ?? '';

return Expect::structure([
'debug' => Expect::bool(false),
'debug' => Expect::bool(interface_exists(IBarPanel::class)),
'connection' => Expect::structure([
'driver' => Expect::string('pdo_mysql'),
'host' => Expect::string('localhost')->nullable(),
Expand All @@ -87,9 +94,9 @@ public function getConfigSchema(): Schema
'schema_filter' => Expect::string()->nullable(),
]),
'prefix' => Expect::string('doctrine.default'),
'proxyDir' => Expect::string('%tempDir%/cache/proxies'),
'proxyDir' => Expect::string($tempDir . '/cache/proxies'),
'proxyNamespace' => Expect::string('DoctrineProxies'),
'sourceDir' => Expect::string()->nullable(),
'sourceDir' => Expect::string()->required(),
'entityManagerClassName' => Expect::string(EntityManager::class),
'defaultRepositoryClassName' => Expect::string(EntityRepository::class),
'repositoryFactory' => Expect::string()->nullable(),
Expand All @@ -99,10 +106,10 @@ public function getConfigSchema(): Schema
'metadata' => Expect::array()->default([]),
'functions' => Expect::array()->default([]),
// caches
'metadataCache' => Expect::string('default'),
'queryCache' => Expect::string('default'),
'resultCache' => Expect::string('default'),
'hydrationCache' => Expect::string('default'),
'metadataCache' => Expect::anyOf(Expect::string(), Expect::bool())->default('default'),
'queryCache' => Expect::anyOf(Expect::string(), Expect::bool())->default('default'),
'resultCache' => Expect::anyOf(Expect::string(), Expect::bool())->default('default'),
'hydrationCache' => Expect::anyOf(Expect::string(), Expect::bool())->default('default'),
'secondLevelCache' => Expect::structure([
'enabled' => Expect::bool(false),
'factoryClass' => Expect::string(DefaultCacheFactory::class),
Expand All @@ -111,7 +118,7 @@ public function getConfigSchema(): Schema
'defaultLifetime' => Expect::int(3600),
'defaultLockLifetime' => Expect::int(60),
]),
'fileLockRegionDirectory' => Expect::string('%tempDir%/cache/Doctrine.Cache.Locks'),
'fileLockRegionDirectory' => Expect::string($tempDir . '/cache/Doctrine.Cache.Locks'),
'logging' => Expect::bool(false),
]),
'cache' => Expect::structure([
Expand Down
1 change: 1 addition & 0 deletions tests/config/config.neon
Expand Up @@ -8,6 +8,7 @@ doctrine:

debug: FALSE
proxyDir: %tempDir%/proxies
sourceDir: %tempDir%/sources
dbal:
types:
interval: Portiny\Doctrine\Tests\Source\IntervalType
Expand Down

0 comments on commit 96f7d28

Please sign in to comment.