fsi-open /
admin-security-bundle
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * (c) FSi sp. z o.o. <[email protected]> |
||
| 5 | * |
||
| 6 | * For the full copyright and license information, please view the LICENSE |
||
| 7 | * file that was distributed with this source code. |
||
| 8 | */ |
||
| 9 | |||
| 10 | namespace FSi\Bundle\AdminSecurityBundle; |
||
| 11 | |||
| 12 | use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass; |
||
| 13 | use FSi\Bundle\AdminSecurityBundle\DependencyInjection\Compiler\FirewallMapCompilerPass; |
||
| 14 | use FSi\Bundle\AdminSecurityBundle\DependencyInjection\Compiler\ValidationCompilerPass; |
||
| 15 | use FSi\Bundle\AdminSecurityBundle\DependencyInjection\FSIAdminSecurityExtension; |
||
| 16 | use LogicException; |
||
| 17 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
| 18 | use Symfony\Component\HttpKernel\Bundle\Bundle; |
||
| 19 | |||
| 20 | class FSiAdminSecurityBundle extends Bundle |
||
| 21 | { |
||
| 22 | public function build(ContainerBuilder $container) |
||
| 23 | { |
||
| 24 | parent::build($container); |
||
| 25 | |||
| 26 | $container->addCompilerPass(new FirewallMapCompilerPass()); |
||
| 27 | $container->addCompilerPass(new ValidationCompilerPass()); |
||
| 28 | |||
| 29 | $doctrineConfigDir = realpath(__DIR__ . '/Resources/config/doctrine'); |
||
| 30 | |||
| 31 | $mappings = [ |
||
| 32 | $doctrineConfigDir . '/User' => 'FSi\Bundle\AdminSecurityBundle\Security\User', |
||
| 33 | $doctrineConfigDir . '/Token' => 'FSi\Bundle\AdminSecurityBundle\Security\Token', |
||
| 34 | ]; |
||
| 35 | |||
| 36 | $container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings)); |
||
| 37 | |||
| 38 | if ($container->hasExtension('fos_user')) { |
||
| 39 | $mappings = [ |
||
| 40 | $doctrineConfigDir . '/FOS' => 'FSi\Bundle\AdminSecurityBundle\Security\FOS', |
||
| 41 | ]; |
||
| 42 | |||
| 43 | $container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings)); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | public function boot() |
||
| 48 | { |
||
| 49 | $userRepository = $this->container->get('admin_security.repository.user'); |
||
| 50 | $expectedRepositoryClass = '\FSi\Bundle\AdminSecurityBundle\Security\User\UserRepositoryInterface'; |
||
| 51 | if (!($userRepository instanceof $expectedRepositoryClass)) { |
||
| 52 | throw new LogicException(sprintf( |
||
| 53 | 'Repository for class "\%s" does not implement the "\%s" interface!', |
||
| 54 | get_class($userRepository), |
||
| 55 | $expectedRepositoryClass |
||
| 56 | )); |
||
| 57 | } |
||
| 58 | |||
| 59 | parent::boot(); |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @return FSIAdminSecurityExtension |
||
| 64 | */ |
||
| 65 | public function getContainerExtension() |
||
| 66 | { |
||
| 67 | if (null === $this->extension) { |
||
| 68 | $this->extension = new FSIAdminSecurityExtension(); |
||
| 69 | } |
||
| 70 | |||
| 71 | return $this->extension; |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 72 | } |
||
| 73 | } |
||
| 74 |