Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CWD
CwdDataDoctrineORMBundle
Commits
8e5557e0
Commit
8e5557e0
authored
Sep 08, 2018
by
Bernhard Schussek
Browse files
Made connections configurable
parent
e9f8e296
Changes
5
Hide whitespace changes
Inline
Side-by-side
CwdDataDoctrineORMBundle.php
View file @
8e5557e0
...
...
@@ -15,6 +15,7 @@ namespace Cwd\DataDoctrineORMBundle;
use
Cwd\DataBundle\DependencyInjection\Compiler\AutoDiscoverRepositoryImplementationsPass
;
use
Cwd\DataBundle\DependencyInjection\Compiler\GenerateRepositoryClassesPass
;
use
Cwd\DataDoctrineORMBundle\DependencyInjection\Compiler\InjectConnectionsPass
;
use
Cwd\DataDoctrineORMBundle\DependencyInjection\Compiler\RegisterFunctionsPass
;
use
Cwd\DataDoctrineORMBundle\DependencyInjection\Compiler\RegisterTypesPass
;
use
Cwd\DataDoctrineORMBundle\DependencyInjection\CwdDataDoctrineORMExtension
;
...
...
@@ -41,5 +42,6 @@ class CwdDataDoctrineORMBundle extends Bundle
));
$container
->
addCompilerPass
(
new
RegisterTypesPass
());
$container
->
addCompilerPass
(
new
RegisterFunctionsPass
());
$container
->
addCompilerPass
(
new
InjectConnectionsPass
());
}
}
DependencyInjection/Compiler/InjectConnectionsPass.php
0 → 100644
View file @
8e5557e0
<?php
/*
* This file is part of neos-crm
*
* (c) 2017 Ludwig Ruderstaller <lr@cwd.at>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare
(
strict_types
=
1
);
namespace
Cwd\DataDoctrineORMBundle\DependencyInjection\Compiler
;
use
Cwd\DataDoctrineORMBundle\Auditing\ORMChangeTimeRecorder
;
use
Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
;
use
Symfony\Component\DependencyInjection\ContainerBuilder
;
class
InjectConnectionsPass
implements
CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public
function
process
(
ContainerBuilder
$containerBuilder
):
void
{
if
(
!
$containerBuilder
->
hasParameter
(
'cwd_data_doctrine_orm.connection'
))
{
return
;
}
$changeTimeRecorder
=
$containerBuilder
->
getDefinition
(
ORMChangeTimeRecorder
::
class
);
$connectionName
=
$containerBuilder
->
getParameter
(
'cwd_data_doctrine_orm.connection'
);
$tags
=
$changeTimeRecorder
->
getTags
();
if
(
!
isset
(
$tags
[
'doctrine.event_listener'
]))
{
return
;
}
foreach
(
$tags
[
'doctrine.event_listener'
]
as
$key
=>
$payload
)
{
$payload
[
'connection'
]
=
$connectionName
;
}
$changeTimeRecorder
->
setTags
(
$tags
);
}
}
DependencyInjection/Configuration.php
View file @
8e5557e0
...
...
@@ -37,6 +37,9 @@ class Configuration implements ConfigurationInterface
->
booleanNode
(
'enabled'
)
->
defaultFalse
()
->
end
()
->
scalarNode
(
'connection'
)
->
defaultValue
(
'default'
)
->
end
()
->
scalarNode
(
'entity_manager'
)
->
defaultValue
(
'default'
)
->
end
()
...
...
DependencyInjection/CwdDataDoctrineORMExtension.php
View file @
8e5557e0
...
...
@@ -46,6 +46,11 @@ class CwdDataDoctrineORMExtension extends ConfigurableExtension
return
;
}
$container
->
setParameter
(
'cwd_data_doctrine_orm.connection'
,
$mergedConfig
[
'connection'
]
);
$container
->
setParameter
(
'cwd_data_doctrine_orm.entity_manager'
,
$mergedConfig
[
'entity_manager'
]
...
...
Resources/config/services.yml
View file @
8e5557e0
...
...
@@ -8,8 +8,8 @@ services:
Cwd\DataDoctrineORMBundle\Auditing\ORMChangeTimeRecorder
:
class
:
Cwd\DataDoctrineORMBundle\Auditing\ORMChangeTimeRecorder
tags
:
-
{
name
:
doctrine.event_listener
,
event
:
prePersist
,
connection
:
default
}
-
{
name
:
doctrine.event_listener
,
event
:
preUpdate
,
connection
:
default
}
-
{
name
:
doctrine.event_listener
,
event
:
prePersist
}
-
{
name
:
doctrine.event_listener
,
event
:
preUpdate
}
Cwd\DataDoctrineORMBundle\Schema\ReferencesOption
:
class
:
Cwd\DataDoctrineORMBundle\Schema\ReferencesOption
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment