-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate config to PHP #810
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Doctrine\Bundle\MongoDBBundle\CacheWarmer\HydratorCacheWarmer; | ||
use Doctrine\Bundle\MongoDBBundle\CacheWarmer\PersistentCollectionCacheWarmer; | ||
use Doctrine\Bundle\MongoDBBundle\CacheWarmer\ProxyCacheWarmer; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
use function Symfony\Component\DependencyInjection\Loader\Configurator\service; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$containerConfigurator->services() | ||
|
||
->set('doctrine_mongodb.odm.proxy_cache_warmer', ProxyCacheWarmer::class) | ||
->tag('kernel.cache_warmer', ['priority' => 25]) | ||
->args([ | ||
service('service_container'), | ||
]) | ||
|
||
->set('doctrine_mongodb.odm.hydrator_cache_warmer', HydratorCacheWarmer::class) | ||
->tag('kernel.cache_warmer', ['priority' => 25]) | ||
->args([ | ||
service('service_container'), | ||
]) | ||
|
||
->set('doctrine_mongodb.odm.persistent_collection_cache_warmer', PersistentCollectionCacheWarmer::class) | ||
->tag('kernel.cache_warmer', ['priority' => 25]) | ||
->args([ | ||
service('service_container'), | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Doctrine\Bundle\MongoDBBundle\Command\ClearMetadataCacheDoctrineODMCommand; | ||
use Doctrine\Bundle\MongoDBBundle\Command\CreateSchemaDoctrineODMCommand; | ||
use Doctrine\Bundle\MongoDBBundle\Command\DropSchemaDoctrineODMCommand; | ||
use Doctrine\Bundle\MongoDBBundle\Command\GenerateHydratorsDoctrineODMCommand; | ||
use Doctrine\Bundle\MongoDBBundle\Command\GenerateProxiesDoctrineODMCommand; | ||
use Doctrine\Bundle\MongoDBBundle\Command\InfoDoctrineODMCommand; | ||
use Doctrine\Bundle\MongoDBBundle\Command\LoadDataFixturesDoctrineODMCommand; | ||
use Doctrine\Bundle\MongoDBBundle\Command\QueryDoctrineODMCommand; | ||
use Doctrine\Bundle\MongoDBBundle\Command\ShardDoctrineODMCommand; | ||
use Doctrine\Bundle\MongoDBBundle\Command\UpdateSchemaDoctrineODMCommand; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
use function Symfony\Component\DependencyInjection\Loader\Configurator\service; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$containerConfigurator->services() | ||
->set('doctrine_mongodb.odm.command.clear_metadata_cache', ClearMetadataCacheDoctrineODMCommand::class) | ||
->tag('console.command', ['command' => 'doctrine:mongodb:cache:clear-metadata']) | ||
|
||
->set('doctrine_mongodb.odm.command.create_schema', CreateSchemaDoctrineODMCommand::class) | ||
->tag('console.command', ['command' => 'doctrine:mongodb:schema:create']) | ||
|
||
->set('doctrine_mongodb.odm.command.drop_schema', DropSchemaDoctrineODMCommand::class) | ||
->tag('console.command', ['command' => 'doctrine:mongodb:schema:drop']) | ||
|
||
->set('doctrine_mongodb.odm.command.generate_hydrators', GenerateHydratorsDoctrineODMCommand::class) | ||
->tag('console.command', ['command' => 'doctrine:mongodb:generate:hydrators']) | ||
|
||
->set('doctrine_mongodb.odm.command.generate_proxies', GenerateProxiesDoctrineODMCommand::class) | ||
->tag('console.command', ['command' => 'doctrine:mongodb:generate:proxies']) | ||
|
||
->set('doctrine_mongodb.odm.command.info', InfoDoctrineODMCommand::class) | ||
->tag('console.command', ['command' => 'doctrine:mongodb:mapping:info']) | ||
->args([ | ||
service('doctrine_mongodb'), | ||
]) | ||
|
||
->set('doctrine_mongodb.odm.command.load_data_fixtures', LoadDataFixturesDoctrineODMCommand::class) | ||
->tag('console.command', ['command' => 'doctrine:mongodb:fixtures:load']) | ||
->args([ | ||
service('doctrine_mongodb'), | ||
service('doctrine_mongodb.odm.symfony.fixtures.loader'), | ||
]) | ||
|
||
->set('doctrine_mongodb.odm.command.query', QueryDoctrineODMCommand::class) | ||
->tag('console.command', ['command' => 'doctrine:mongodb:query']) | ||
|
||
->set('doctrine_mongodb.odm.command.shard', ShardDoctrineODMCommand::class) | ||
->tag('console.command', ['command' => 'doctrine:mongodb:schema:shard']) | ||
|
||
->set('doctrine_mongodb.odm.command.update_schema', UpdateSchemaDoctrineODMCommand::class) | ||
->tag('console.command', ['command' => 'doctrine:mongodb:schema:update']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Doctrine\Bundle\MongoDBBundle\Form\DoctrineMongoDBTypeGuesser; | ||
use Doctrine\Bundle\MongoDBBundle\Form\Type\DocumentType; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
use function Symfony\Component\DependencyInjection\Loader\Configurator\service; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$containerConfigurator->services() | ||
|
||
->set('form.type.mongodb_document', DocumentType::class) | ||
->tag('form.type', ['alias' => 'document']) | ||
->args([ | ||
service('doctrine_mongodb'), | ||
]) | ||
|
||
->set('form.type_guesser.doctrine.mongodb', DoctrineMongoDBTypeGuesser::class) | ||
->tag('form.type_guesser') | ||
->args([ | ||
service('doctrine_mongodb'), | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Doctrine\Bundle\MongoDBBundle\APM\CommandLoggerRegistry; | ||
use Doctrine\Bundle\MongoDBBundle\APM\PSRCommandLogger; | ||
use Doctrine\Bundle\MongoDBBundle\APM\StopwatchCommandLogger; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
use function Symfony\Component\DependencyInjection\Loader\Configurator\service; | ||
use function Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$containerConfigurator->services() | ||
|
||
->set('doctrine_mongodb.odm.command_logger_registry', CommandLoggerRegistry::class) | ||
->public() | ||
->args([ | ||
tagged_iterator('doctrine_mongodb.odm.command_logger'), | ||
]) | ||
|
||
->set('doctrine_mongodb.odm.stopwatch_command_logger', StopwatchCommandLogger::class) | ||
->args([ | ||
service('debug.stopwatch')->nullOnInvalid(), | ||
]) | ||
|
||
->set('doctrine_mongodb.odm.psr_command_logger', PSRCommandLogger::class) | ||
->tag('monolog.logger', ['channel' => 'doctrine']) | ||
->args([ | ||
service('logger')->nullOnInvalid(), | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Symfony\Bridge\Doctrine\Messenger\DoctrineClearEntityManagerWorkerSubscriber; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
use function Symfony\Component\DependencyInjection\Loader\Configurator\service; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$services = $containerConfigurator->services(); | ||
|
||
$services->set('doctrine_mongodb.messenger.event_subscriber.doctrine_clear_document_manager', DoctrineClearEntityManagerWorkerSubscriber::class) | ||
->tag('kernel.event_subscriber') | ||
->args([ | ||
service('doctrine_mongodb'), | ||
]); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Doctrine\Bundle\MongoDBBundle\Loader\SymfonyFixturesLoader; | ||
use Doctrine\Bundle\MongoDBBundle\ManagerConfigurator; | ||
use Doctrine\Bundle\MongoDBBundle\ManagerRegistry; | ||
use Doctrine\Bundle\MongoDBBundle\Mapping\Driver\XmlDriver; | ||
use Doctrine\Bundle\MongoDBBundle\Repository\ContainerRepositoryFactory; | ||
use Doctrine\ODM\MongoDB\DocumentManager; | ||
use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver; | ||
use Doctrine\ODM\MongoDB\Tools\ResolveTargetDocumentListener; | ||
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; | ||
use ProxyManager\Proxy\GhostObjectInterface; | ||
use Symfony\Bridge\Doctrine\ContainerAwareEventManager; | ||
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
use function Symfony\Component\DependencyInjection\Loader\Configurator\abstract_arg; | ||
use function Symfony\Component\DependencyInjection\Loader\Configurator\service; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$containerConfigurator->parameters() | ||
->set('doctrine_mongodb.odm.cache.array.class', 'Doctrine\Common\Cache\ArrayCache') | ||
->set('doctrine_mongodb.odm.cache.apc.class', 'Doctrine\Common\Cache\ApcCache') | ||
->set('doctrine_mongodb.odm.cache.apcu.class', 'Doctrine\Common\Cache\ApcuCache') | ||
->set('doctrine_mongodb.odm.cache.memcache.class', 'Doctrine\Common\Cache\MemcacheCache') | ||
->set('doctrine_mongodb.odm.cache.memcache_host', 'localhost') | ||
->set('doctrine_mongodb.odm.cache.memcache_port', 11211) | ||
->set('doctrine_mongodb.odm.cache.memcache_instance.class', 'Memcache') | ||
->set('doctrine_mongodb.odm.cache.xcache.class', 'Doctrine\Common\Cache\XcacheCache') | ||
->set('doctrine_mongodb.odm.metadata.driver_chain.class', MappingDriverChain::class) | ||
->set('doctrine_mongodb.odm.metadata.attribute.class', AttributeDriver::class) | ||
->set('doctrine_mongodb.odm.metadata.xml.class', XmlDriver::class); | ||
|
||
$containerConfigurator->services() | ||
|
||
->alias(DocumentManager::class, 'doctrine_mongodb.odm.document_manager') | ||
|
||
->alias(ManagerRegistry::class, 'doctrine_mongodb') | ||
|
||
->set('doctrine_mongodb.odm.connection.event_manager', ContainerAwareEventManager::class) | ||
->abstract() | ||
->args([ | ||
service('service_container'), | ||
]) | ||
|
||
->set('doctrine_mongodb.odm.container_repository_factory', ContainerRepositoryFactory::class) | ||
->args([ | ||
abstract_arg('service locator'), | ||
]) | ||
|
||
->set('doctrine_mongodb.odm.manager_configurator.abstract', ManagerConfigurator::class) | ||
->abstract() | ||
->args([ | ||
abstract_arg('enabled filters'), | ||
]) | ||
|
||
->set('doctrine_mongodb.odm.security.user.provider', EntityUserProvider::class) | ||
->abstract() | ||
->args([ | ||
service('doctrine_mongodb'), | ||
]) | ||
|
||
->set('doctrine_mongodb', ManagerRegistry::class) | ||
->public() | ||
->args([ | ||
'MongoDB', | ||
'%doctrine_mongodb.odm.connections%', | ||
'%doctrine_mongodb.odm.document_managers%', | ||
'%doctrine_mongodb.odm.default_connection%', | ||
'%doctrine_mongodb.odm.default_document_manager%', | ||
GhostObjectInterface::class, | ||
service('service_container'), | ||
]) | ||
|
||
->set('doctrine_mongodb.odm.listeners.resolve_target_document', ResolveTargetDocumentListener::class) | ||
|
||
->set('doctrine_mongodb.odm.symfony.fixtures.loader', SymfonyFixturesLoader::class); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to #811, the parameters should be deprecated here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is partially related to #804, these parameters are apparently used in the AbstractDoctrineExtension, this is the code related about cache:
https://github.com/symfony/symfony/blob/e0df5c3d9c0281cdfe3885281145e2065b859d32/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php#L340-L406
And the related to the metadata:
https://github.com/symfony/symfony/blob/e0df5c3d9c0281cdfe3885281145e2065b859d32/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php#L193-L228
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we stop using them, we have to keep and deprecate them in 2.x, as they could be used in applications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that since these parameters seem to be used for internal configuration, maybe Symfony can try to fetch them first as build parameters (prefixing the parameter with a ".") and fallback to "normal", I'll see if I have time tomorrow to open a PR there for that.
Update: Symfony always calls an abstract method that is implemented in our side to get the parameter name, so the build parameters can be implemented in our side I think.
Update2: We can do it for metadata parameters, but for cache parameters I think need to be done in the
AbstractDoctrineExtension
, I'll take a look tomorrow if I find some time.