-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add community manager service compiler pass
- Loading branch information
1 parent
df4ab1e
commit 7f0ebaf
Showing
5 changed files
with
93 additions
and
68 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
DependencyInjection/CompilerPass/CommunityManagerCompilerPass.php
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,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) MASSIVE ART WebServices GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\CommunityBundle\DependencyInjection\CompilerPass; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* Create foreach configured webspace a community manager. | ||
*/ | ||
class CommunityManagerCompilerPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$container->getParameter('sulu_community.config'); | ||
|
||
foreach ($config[Configuration::WEBSPACES] as $webspaceKey => $webspaceConfig) { | ||
// Set firewall by webspace key | ||
if ($webspaceConfig[Configuration::FIREWALL] === null) { | ||
$webspaceConfig[Configuration::FIREWALL] = $webspaceKey; | ||
} | ||
|
||
// Set role by webspace key | ||
if ($webspaceConfig[Configuration::ROLE] === null) { | ||
$webspaceConfig[Configuration::ROLE] = ucfirst($webspaceKey) . 'User'; | ||
} | ||
|
||
$definition = new DefinitionDecorator('sulu_community.community_manager'); | ||
$definition->replaceArgument(0, $webspaceConfig); | ||
$definition->replaceArgument(1, $webspaceKey); | ||
|
||
$container->setDefinition( | ||
sprintf('sulu_community.%s.community_manager', $webspaceKey), | ||
$definition | ||
); | ||
} | ||
} | ||
} |
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
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