-
Notifications
You must be signed in to change notification settings - Fork 4
Refactoring #9
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
Open
beberlei
wants to merge
28
commits into
master
Choose a base branch
from
Refactoring
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactoring #9
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
edd590f
䅤摥搠瑥獴猠景爠呲慮獡捴楯湡汍慴捨敲�
yethee 84aa839
Fixed a class name
yethee 9627d7f
Merge pull request #6 from yethee/tests_and_fixes
beberlei 92fce37
Merge pull request #7 from yethee/em_transaction
beberlei 284913b
Start refactoring away from wrapper
beberlei 4ef43e1
Merge branch 'master' of github.com:simplethings/SimpleThingsTransact…
beberlei a2f255e
Checkpoint Refactoring. Removed all old Managers, reworked Transactio…
beberlei 0a52ba7
Remove Request dependency from TransactionalMatcher
beberlei f6b794f
Implement and test AbstractTransactionManager, Rename ControllerListe…
beberlei 24f3b82
Move all non-configuration Files under Transactions namespace. Testin…
beberlei e44abbb
Implement ObjectTransactionManager and Status. Started writing DESIGN…
beberlei bec3deb
Remove HttpTransactionsListener in Controller folder
beberlei 6b5f83d
Refactor towards Transactional Scope
beberlei 7f8e51f
Add Functional Test, work on configuration, add OrmTransactionManager.
beberlei b7a05ac
Typo
beberlei b11b03f
Simplified transactions code by allowing only one manager per request…
beberlei ca42251
Get rid of the PROPAGATION, ISOLATION overhead and back to simple again.
beberlei eb6ee97
More renaming, get rid of managers, only have providers, registry man…
beberlei c03fba8
Remove txdef from request
beberlei 51149fd
Further refactoring, cleaned up DI extension, added tests for Container
beberlei 94e9a6d
Fix Form Support
beberlei ccfbc51
Update README
beberlei bdaf28f
Test Object/ORM Providers and fix some bugs.
beberlei e5b8a29
Fix use statements
yethee 4c036a3
Extracted dependency of the validator, inject it through the construc…
yethee ce97a4b
Fixes some typo
yethee 2e27d91
Fixed commit ORM transaction
yethee d88126e
Merge pull request #10 from yethee/refactoring_bugfix
beberlei 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,77 @@ | ||
| <?php | ||
| /** | ||
| * SimpleThings TransactionalBundle | ||
| * | ||
| * LICENSE | ||
| * | ||
| * This source file is subject to the new BSD license that is bundled | ||
| * with this package in the file LICENSE.txt. | ||
| * If you did not receive a copy of the license and are unable to | ||
| * obtain it through the world-wide-web, please send an email | ||
| * to kontakt@beberlei.de so I can send you a copy immediately. | ||
| */ | ||
|
|
||
| namespace SimpleThings\TransactionalBundle\DependencyInjection\CompilerPass; | ||
|
|
||
| use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
| use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
| use Symfony\Component\DependencyInjection\Reference; | ||
| use Symfony\Component\DependencyInjection\DefinitionDecorator; | ||
|
|
||
| /** | ||
| * Detects connections and registers the transaction manager services. | ||
| */ | ||
| class DetectConnectionsPass implements CompilerPassInterface | ||
| { | ||
| public function process(ContainerBuilder $builder) | ||
| { | ||
| /* if ($builder->hasParameter('doctrine.connections')) { | ||
| foreach ($builder->getParameter('doctrine.connections') AS $alias => $service) { | ||
| $builder->setDefinition( | ||
| 'simple_things_transactional.tx.dbal.'.$alias, | ||
| new DefinitionDecorator('simple_things_transactional.manager.dbal') | ||
| )->setArguments(array(new Reference($service))); | ||
| } | ||
| } | ||
| */ | ||
| $connectionServices = array(); | ||
|
|
||
| if ($builder->hasParameter('doctrine.entity_managers')) { | ||
| foreach ($builder->getParameter('doctrine.entity_managers') AS $alias => $service) { | ||
| $connectionServices[] = 'doctrine.orm.' . $alias . '_entity_manager'; | ||
| $builder->setAlias( | ||
| 'simple_things_transactional.connections.orm.' . $alias, | ||
| 'doctrine.orm.' . $alias . '_entity_manager' | ||
| ); | ||
| $builder->setDefinition( | ||
| 'simple_things_transactional.tx.orm.'.$alias, | ||
| new DefinitionDecorator('simple_things_transactional.manager.orm') | ||
| )->setArguments(array(new Reference('service_container'))); | ||
| } | ||
| } | ||
|
|
||
| if ($builder->hasParameter('doctrine_couchdb.document_managers')) { | ||
| foreach ($builder->getParameter('doctrine_couchdb.document_managers') AS $alias => $service) { | ||
| $connectionServices[] = 'doctrine_couchdb.odm.' . $alias . '_document_manager'; | ||
| $builder->setAlias('simple_things_transactional.connections.couchdb.' . $alias | ||
| $builder->setDefinition( | ||
| 'simple_things_transactional.tx.couchdb.'.$alias, | ||
| new DefinitionDecorator('simple_things_transactional.manager.object_manager') | ||
| )->setArguments(array(new Reference('service_container'))); | ||
| } | ||
| } | ||
|
|
||
| if ($builder->hasParameter('doctrine_mongodb.document_managers')) { | ||
| foreach ($builder->getParameter('doctrine_mongodb.document_managers') AS $alias => $service) { | ||
| $connectionServices[] = 'doctrine_mongodb.odm.' . $alias . '_document_manager'; | ||
| $builder->setAlias('simple_things_transactional.connections.mongodb.' . $alias | ||
| $builder->setDefinition( | ||
| 'simple_things_transactional.tx.mongodb.'.$alias, | ||
| new DefinitionDecorator('simple_things_transactional.manager.object_manager') | ||
| )->setArguments(array(new Reference('service_container'))); | ||
| } | ||
| } | ||
| // add tags as well for external resources (Propel, raw-PDO whatever) | ||
| $container->setParameter('simple_things_transactional.connection_services', $connectionServices); | ||
| } | ||
| } |
59 changes: 59 additions & 0 deletions
59
DependencyInjection/CompilerPass/TransactionalScopePass.php
This file contains hidden or 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,59 @@ | ||
| <?php | ||
| /** | ||
| * SimpleThings TransactionalBundle | ||
| * | ||
| * LICENSE | ||
| * | ||
| * This source file is subject to the new BSD license that is bundled | ||
| * with this package in the file LICENSE.txt. | ||
| * If you did not receive a copy of the license and are unable to | ||
| * obtain it through the world-wide-web, please send an email | ||
| * to kontakt@beberlei.de so I can send you a copy immediately. | ||
| */ | ||
|
|
||
| namespace SimpleThings\TransactionalBundle\DependencyInjection\CompilerPass; | ||
|
|
||
| use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
| use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
|
||
| /** | ||
| * Scope changes the scope of ALL container scoped services from | ||
| * 'container' to 'transactional' if they depend on any transactional | ||
| * connection resource. | ||
| * | ||
| * @author Benjamin Eberlei <kontakt@beberlei.de> | ||
| */ | ||
| class TransactionalScopePass implements CompilerPassInterface | ||
| { | ||
| public function process(ContainerBuilder $container) | ||
| { | ||
| $connectionServices = $container->getParameter('simple_things_transactional.connection_serices'); | ||
| $graph = $container->getCompiler()->getServiceReferenceGraph(); | ||
|
|
||
| $visited = array(); | ||
| foreach ($connectionServices as $connectionServiceId) { | ||
| $this->changeScopeTransactional($connectionServiceId, $visited); | ||
| } | ||
| } | ||
|
|
||
| private function changeScopeTransactional($serviceId, $visited) | ||
| { | ||
| if (isset($visited[$serviceId])) { | ||
| return; | ||
| } | ||
| $visited[$serviceId] = true; | ||
|
|
||
| $node = $graph->getNode($serviceId); | ||
| $def = $container->getDefinition($serviceId); | ||
|
|
||
| if ($def->getScope() == ContainerInterface::SCOPE_CONTAINER) { | ||
| $def->setScope('transactional'); | ||
| } | ||
|
|
||
| foreach ($node->getOutNodes() as $outNode) { | ||
| $this->changeScopeTransactional($outNode->getId(), $visited); | ||
| } | ||
| } | ||
| } | ||
|
|
||
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.
I think this should be inEdges as you are interested in all services that have a dependency on the connection (in contrast to all dependencies that the connection has onto other services).