|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Zikula package. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright Zikula - https://ziku.la/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Zikula\UsersBundle\DependencyInjection; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\Config\FileLocator; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
|
20
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
21
|
|
|
use Zikula\UsersBundle\Form\Type\AvatarType; |
|
22
|
|
|
use Zikula\UsersBundle\Helper\MailHelper; |
|
23
|
|
|
use Zikula\UsersBundle\Helper\ProfileHelper; |
|
24
|
|
|
use Zikula\UsersBundle\Helper\UploadHelper; |
|
25
|
|
|
use Zikula\UsersBundle\Menu\ExtensionMenu; |
|
26
|
|
|
use Zikula\UsersBundle\Twig\Runtime\ProfileRuntime; |
|
27
|
|
|
|
|
28
|
|
|
class ZikulaUsersExtension extends Extension implements PrependExtensionInterface |
|
29
|
|
|
{ |
|
30
|
|
|
private ?bool $isNucleosSelfDeletionEnabled = null; |
|
31
|
|
|
|
|
32
|
|
|
public function prepend(ContainerBuilder $containerBuilder) |
|
33
|
|
|
{ |
|
34
|
|
|
// get all bundles |
|
35
|
|
|
$bundles = $containerBuilder->getParameter('kernel.bundles'); |
|
36
|
|
|
if (isset($bundles['NucleosUserBundle'])) { |
|
37
|
|
|
$config = $containerBuilder->getExtensionConfig('nucleos_user')[0]; |
|
38
|
|
|
$this->isNucleosSelfDeletionEnabled = $config['deletion']['enabled'] ?? null; |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
43
|
|
|
{ |
|
44
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__) . '/Resources/config')); |
|
45
|
|
|
$loader->load('services.yaml'); |
|
46
|
|
|
|
|
47
|
|
|
$configuration = new Configuration(); |
|
48
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
49
|
|
|
|
|
50
|
|
|
$container->getDefinition(ExtensionMenu::class) |
|
51
|
|
|
->setArgument('$registrationEnabled', $config['registration']['enabled']) |
|
52
|
|
|
->setArgument('$allowSelfDeletion', $this->isNucleosSelfDeletionEnabled ?? $config['allow_self_deletion']); |
|
53
|
|
|
|
|
54
|
|
|
$container->getDefinition(AvatarType::class) |
|
55
|
|
|
->setArgument('$avatarConfig', $config['avatar']); |
|
56
|
|
|
|
|
57
|
|
|
$container->getDefinition(MailHelper::class) |
|
58
|
|
|
->setArgument('$registrationNotificationEmail', $config['registration']['admin_notification_mail']); |
|
59
|
|
|
|
|
60
|
|
|
$container->getDefinition(ProfileHelper::class) |
|
61
|
|
|
->setArgument('$avatarImagePath', $config['avatar']['image_path']) |
|
62
|
|
|
->setArgument('$avatarDefaultImage', $config['avatar']['default_image']) |
|
63
|
|
|
->setArgument('$gravatarEnabled', $config['avatar']['gravatar_enabled']); |
|
64
|
|
|
|
|
65
|
|
|
$container->getDefinition(UploadHelper::class) |
|
66
|
|
|
->setArgument('$uploadConfig', $config['avatar']['uploads']) |
|
67
|
|
|
->setArgument('$imagePath', $config['avatar']['image_path']); |
|
68
|
|
|
|
|
69
|
|
|
$container->getDefinition(ProfileRuntime::class) |
|
70
|
|
|
->setArgument('$displayRegistrationDate', $config['display_registration_date']); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|