Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,30 @@ grumphp:
doctrine_schema_validate:
skip_mapping: false
skip_sync: false
skip_property_types: false
em: default
triggered_by: ['php', 'xml', 'yml']
extensions:
- JonMldr\GrumPhpDoctrineTask\ExtensionLoader
````

For multiple entity managers you can specify the entity manager to be used:
````YAML
# grumphp.yml
grumphp:
tasks:
doctrine_schema_validate_application:
em: application
metadata:
task: doctrine_schema_validate
doctrine_schema_validate_reporting:
em: reporting
metadata:
task: doctrine_schema_validate
extensions:
- JonMldr\GrumPhpDoctrineTask\ExtensionLoader
````

**console_path**

*Default: 'bin/console'*
Expand All @@ -54,11 +73,27 @@ With this parameter you can skip checking if the mapping is in sync with the dat

This is a list of extensions that should trigger the Doctrine task.

**em**

*Default: null*

Require `doctrine/orm >= 3.0`.
Specify the entity manager to be used. If not set, the default entity manager will be used.

**skip_property_types**

*Default: null*

Require `doctrine/orm >= 3.0`.
With this parameter you can skip checking if property types match the Doctrine types.

## Changelog
### Version 3.1
* Added `docker-compose.yml` file for local development
* Allowed `phpro/grumphp` Composer plugin
* Updated Dockerfile
* Add `em` option thanks to [@majoskorec](https://github.com/majoskorec)
* Add `skip_property_types` option thanks to [@majoskorec](https://github.com/majoskorec)

### Version 3.0
* Upgraded GrumPHP version to `^2.0` thanks to [@erkens](https://github.com/erkens)
Expand Down
14 changes: 13 additions & 1 deletion src/DoctrineSchemaValidateTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ public static function getConfigurableOptions(): ConfigOptionsResolver
'console_path' => 'bin/console',
'skip_mapping' => false,
'skip_sync' => false,
'skip_property_types' => null,
'em' => null,
'triggered_by' => ['php', 'xml', 'yml'],
]);

$resolver->addAllowedTypes('skip_mapping', ['bool'])
->addAllowedTypes('skip_sync', ['bool'])
->addAllowedTypes('triggered_by', ['array']);
->addAllowedTypes('skip_property_types', ['null', 'bool'])
->addAllowedTypes('triggered_by', ['array'])
->addAllowedTypes('em', ['null', 'string']);

return ConfigOptionsResolver::fromClosure(
static fn (array $options): array => $resolver->resolve($options)
Expand All @@ -67,6 +71,14 @@ public function run(ContextInterface $context): TaskResultInterface
$arguments->add('doctrine:schema:validate');
$arguments->addOptionalArgument('--skip-mapping', $config['skip_mapping']);
$arguments->addOptionalArgument('--skip-sync', $config['skip_sync']);
$skipPropertyTypes = $config['skip_property_types'] ?? null;
if (is_bool($skipPropertyTypes)) {
$arguments->addOptionalArgument('--skip-property-types', $config['skip_property_types']);
}
$em = $config['em'] ?? null;
if (is_string($em)) {
$arguments->addOptionalArgument('--em=%s', $em);
}

$process = $this->processBuilder->buildProcess($arguments);
$process->run();
Expand Down