Skip to content

Commit

Permalink
Renamed configuration parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
SavageDays committed Sep 5, 2023
1 parent 69958fb commit 4e6ebb3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ simple_things_entity_audit:
If there is no need to create foreign keys for any reason, you can specify the corresponding parameter:
```yaml
simple_things_entity_audit:
with_foreign_keys: false
disable_foreign_keys: true
```
### Creating new tables
Expand Down
10 changes: 5 additions & 5 deletions src/AuditConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AuditConfiguration
*/
private array $auditedEntityClasses = [];

private bool $withForeignKeys = true;
private bool $disableForeignKeys = false;

/**
* @var string[]
Expand Down Expand Up @@ -81,14 +81,14 @@ public function getTableName(ClassMetadataInfo $metadata)
return $this->getTablePrefix().$tableName.$this->getTableSuffix();
}

public function getWithForeignKeys(): bool
public function isDisabledForeignKeys(): bool
{
return $this->withForeignKeys;
return $this->disableForeignKeys;
}

public function setWithForeignKeys(bool $withForeignKeys): void
public function setDisabledForeignKeys(bool $disabled): void
{
$this->withForeignKeys = $withForeignKeys;
$this->disableForeignKeys = $disabled;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getConfigTreeBuilder()
->scalarNode('revision_field_name')->defaultValue('rev')->end()
->scalarNode('revision_type_field_name')->defaultValue('revtype')->end()
->scalarNode('revision_table_name')->defaultValue('revisions')->end()
->scalarNode('with_foreign_keys')->defaultValue(true)->end()
->scalarNode('disable_foreign_keys')->defaultValue(false)->end()
->scalarNode('revision_id_field_type')
->defaultValue(Types::INTEGER)
// NEXT_MAJOR: Use enumNode() instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function load(array $configs, ContainerBuilder $container): void
'revision_table_name',
'revision_id_field_type',
'global_ignore_columns',
'with_foreign_keys',
'disable_foreign_keys',
];

foreach ($configurables as $key) {
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/CreateSchemaListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $eventArgs)
}
}

if ($this->config->getWithForeignKeys()) {
if (!$this->config->isDisabledForeignKeys()) {
$this->createForeignKeys($revisionTable, $revisionsTable);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/config/auditable.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

->set('simplethings.entityaudit.revision_id_field_type', null)

->set('simplethings.entityaudit.with_foreign_keys', null);
->set('simplethings.entityaudit.disable_foreign_keys', null);

$containerConfigurator->services()
->set('simplethings_entityaudit.manager', AuditManager::class)
Expand Down Expand Up @@ -121,7 +121,7 @@
->set('simplethings_entityaudit.config', AuditConfiguration::class)
->public()
->call('setAuditedEntityClasses', [param('simplethings.entityaudit.audited_entities')])
->call('setWithForeignKeys', [param('simplethings.entityaudit.with_foreign_keys')])
->call('setDisabledForeignKeys', [param('simplethings.entityaudit.disable_foreign_keys')])
->call('setGlobalIgnoreColumns', [param('simplethings.entityaudit.global_ignore_columns')])
->call('setTablePrefix', [param('simplethings.entityaudit.table_prefix')])
->call('setTableSuffix', [param('simplethings.entityaudit.table_suffix')])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testItRegistersDefaultServices(): void
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall('simplethings_entityaudit.config', 'setRevisionIdFieldType', ['%simplethings.entityaudit.revision_id_field_type%']);
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall('simplethings_entityaudit.config', 'setRevisionFieldName', ['%simplethings.entityaudit.revision_field_name%']);
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall('simplethings_entityaudit.config', 'setRevisionTypeFieldName', ['%simplethings.entityaudit.revision_type_field_name%']);
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall('simplethings_entityaudit.config', 'setWithForeignKeys', ['%simplethings.entityaudit.with_foreign_keys%']);
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall('simplethings_entityaudit.config', 'setDisabledForeignKeys', ['%simplethings.entityaudit.disable_foreign_keys%']);
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall('simplethings_entityaudit.config', 'setUsernameCallable', ['simplethings_entityaudit.username_callable']);
}

Expand Down Expand Up @@ -103,7 +103,7 @@ public function testItSetsDefaultParameters(): void
$this->assertContainerBuilderHasParameter('simplethings.entityaudit.revision_field_name', 'rev');
$this->assertContainerBuilderHasParameter('simplethings.entityaudit.revision_type_field_name', 'revtype');
$this->assertContainerBuilderHasParameter('simplethings.entityaudit.revision_id_field_type', Types::INTEGER);
$this->assertContainerBuilderHasParameter('simplethings.entityaudit.with_foreign_keys', true);
$this->assertContainerBuilderHasParameter('simplethings.entityaudit.disable_foreign_keys', false);
}

public function testItSetsConfiguredParameters(): void
Expand All @@ -119,7 +119,7 @@ public function testItSetsConfiguredParameters(): void
'revision_id_field_type' => Types::GUID,
'revision_field_name' => 'revision',
'revision_type_field_name' => 'action',
'with_foreign_keys' => true,
'disable_foreign_keys' => false,
]);

$this->assertContainerBuilderHasParameter('simplethings.entityaudit.connection', 'my_custom_connection');
Expand All @@ -132,7 +132,7 @@ public function testItSetsConfiguredParameters(): void
$this->assertContainerBuilderHasParameter('simplethings.entityaudit.revision_id_field_type', Types::GUID);
$this->assertContainerBuilderHasParameter('simplethings.entityaudit.revision_field_name', 'revision');
$this->assertContainerBuilderHasParameter('simplethings.entityaudit.revision_type_field_name', 'action');
$this->assertContainerBuilderHasParameter('simplethings.entityaudit.with_foreign_keys', true);
$this->assertContainerBuilderHasParameter('simplethings.entityaudit.disable_foreign_keys', false);

foreach ([Events::onFlush, Events::postPersist, Events::postUpdate, Events::postFlush, Events::onClear] as $event) {
$this->assertContainerBuilderHasServiceDefinitionWithTag('simplethings_entityaudit.log_revisions_listener', 'doctrine.event_listener', ['event' => $event, 'connection' => 'my_custom_connection']);
Expand Down
2 changes: 1 addition & 1 deletion tests/NoForeignKeysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function getAuditManager(): AuditManager

$auditConfig = AuditConfiguration::forEntities($this->auditedEntities);
$auditConfig->setGlobalIgnoreColumns(['ignoreme']);
$auditConfig->setWithForeignKeys(false);
$auditConfig->setDisabledForeignKeys(true);
$auditConfig->setUsernameCallable(static fn (): string => 'beberlei');

$this->auditManager = new AuditManager($auditConfig, $this->getClock());
Expand Down

0 comments on commit 4e6ebb3

Please sign in to comment.