Skip to content

Commit

Permalink
Merge pull request #2 from mapbender/fix/container-usage-Symfony3.4
Browse files Browse the repository at this point in the history
Fix container usage for Symfony 3.4
  • Loading branch information
PhilVanB authored Dec 9, 2021
2 parents df9339b + f7e892c commit e5732d6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
11 changes: 9 additions & 2 deletions DependencyInjection/Compiler/OverwriteIdentitiesProviderPass.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<?php

namespace Mapbender\LDAPBundle\DependencyInjection\Compiler;
namespace Mapbender\LDAPBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class OverwriteIdentitiesProviderPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$container->setParameter("fom.identities.provider.class", "Mapbender\LDAPBundle\Security\Provider\LDAPIdentitiesProvider");

$container->register('fom.identities.provider', "Mapbender\LDAPBundle\Security\Provider\LDAPIdentitiesProvider")
->addArgument(new Reference('doctrine'))
->addArgument(new Reference('fom.ldap_user_identities_provider'))
->addArgument('%fom.user_entity%')
->addArgument(new Reference('service_container'))
;
}
}
18 changes: 15 additions & 3 deletions Security/Provider/LDAPIdentitiesProvider.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
<?php

namespace Mapbender\LDAPBundle\Security\Provider;

use Doctrine\Persistence\ManagerRegistry;
use Mapbender\LDAPBundle\Security\User\LDAPUser as User;
use Mapbender\LDAPBundle\Security\User\LDAPGroup as Group;
use Mapbender\LDAPBundle\Exceptions\MissconfiguredLDAPClientException;
use FOM\UserBundle\Component\Ldap;
use Symfony\Component\DependencyInjection\ContainerInterface as Container;

class LDAPIdentitiesProvider extends \FOM\UserBundle\Component\FOMIdentitiesProvider
{
protected $container;

public function __construct(ManagerRegistry $doctrineRegistry, Ldap\UserProvider $ldapUserProvider, $userEntityClass, Container $container)
{
parent::__construct($doctrineRegistry, $ldapUserProvider, $userEntityClass);
$this->container = $container;
}

public function getAllUsers()
{
Expand All @@ -28,7 +40,7 @@ public function getAllUsers()
if(isset($ldapUser[$nameAttribute][0])){
$user[] = new User($ldapUser[$nameAttribute][0]);
}

}

}
Expand Down Expand Up @@ -72,8 +84,8 @@ public function getAllGroups()
if(isset($ldapGroup[$groupIdentifier])){
$groups[] = new Group($ldapGroup[$groupIdentifier][0]);
}


}

}
Expand Down

0 comments on commit e5732d6

Please sign in to comment.