Browse code

[Update] Added createNewUser Hook

Sebastian Zoglowek authored on26/02/2022 03:03:40
Showing3 changed files
... ...
@@ -5,7 +5,12 @@ declare(strict_types=1);
5 5
 /*
6 6
  * This file is part of Oveleon ContaoMemberExtension Bundle.
7 7
  *
8
- * (c) https://www.oveleon.de/
8
+ * @package     contao-member-extension-bundle
9
+ * @license     MIT
10
+ * @author      Daniele Sciannimanica   <https://github.com/doishub>
11
+ * @author      Fabian Ekert            <https://github.com/eki89>
12
+ * @author      Sebastian Zoglowek      <https://github.com/zoglo>
13
+ * @copyright   Oveleon                 <https://www.oveleon.de/>
9 14
  */
10 15
 
11 16
 namespace Oveleon\ContaoMemberExtensionBundle\ContaoManager;
... ...
@@ -15,7 +20,6 @@ use Contao\ManagerPlugin\Bundle\BundlePluginInterface;
15 20
 use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
16 21
 use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
17 22
 use Oveleon\ContaoMemberExtensionBundle\ContaoMemberExtensionBundle;
18
-use Symfony\Component\HttpKernel\KernelInterface;
19 23
 
20 24
 class Plugin implements BundlePluginInterface
21 25
 {
... ...
@@ -5,7 +5,12 @@ declare(strict_types=1);
5 5
 /*
6 6
  * This file is part of Oveleon ContaoMemberExtension Bundle.
7 7
  *
8
- * (c) https://www.oveleon.de/
8
+ * @package     contao-member-extension-bundle
9
+ * @license     MIT
10
+ * @author      Daniele Sciannimanica   <https://github.com/doishub>
11
+ * @author      Fabian Ekert            <https://github.com/eki89>
12
+ * @author      Sebastian Zoglowek      <https://github.com/zoglo>
13
+ * @copyright   Oveleon                 <https://www.oveleon.de/>
9 14
  */
10 15
 
11 16
 namespace Oveleon\ContaoMemberExtensionBundle;
... ...
@@ -1,31 +1,43 @@
1 1
 <?php
2 2
 
3
+declare(strict_types=1);
4
+
3 5
 /*
4 6
  * This file is part of Oveleon ContaoMemberExtension Bundle.
5 7
  *
6
- * (c) https://www.oveleon.de/
8
+ * @package     contao-member-extension-bundle
9
+ * @license     MIT
10
+ * @author      Daniele Sciannimanica   <https://github.com/doishub>
11
+ * @author      Fabian Ekert            <https://github.com/eki89>
12
+ * @author      Sebastian Zoglowek      <https://github.com/zoglo>
13
+ * @copyright   Oveleon                 <https://www.oveleon.de/>
7 14
  */
8 15
 
9 16
 // Back end modules
17
+use Contao\System;
18
+
10 19
 $GLOBALS['BE_MOD']['system']['member_settings'] = array
11 20
 (
12
-    'tables'            => array('tl_member_settings'),
21
+    'tables'            => ['tl_member_settings'],
13 22
     'hideInNavigation'  => true,
14 23
 );
15 24
 
16 25
 // Front end modules
17
-array_insert($GLOBALS['FE_MOD']['user'], -1, array
18
-(
26
+// ToDo: Change to ArrayUtil::arrayInsert in the future
27
+array_insert($GLOBALS['FE_MOD']['user'], -1, [
19 28
     'avatar'       => 'Oveleon\ContaoMemberExtensionBundle\ModuleAvatar',
20 29
     'memberList'   => 'Oveleon\ContaoMemberExtensionBundle\ModuleMemberList',
21 30
     'memberReader' => 'Oveleon\ContaoMemberExtensionBundle\ModuleMemberReader'
22
-));
31
+]);
23 32
 
24 33
 // Register hooks
25
-$GLOBALS['TL_HOOKS']['updatePersonalData'][] = array('Oveleon\ContaoMemberExtensionBundle\Member', 'updateAvatar');
34
+$GLOBALS['TL_HOOKS']['createNewUser'][] = ['Oveleon\ContaoMemberExtensionBundle\Member', 'createAvatar'];
35
+$GLOBALS['TL_HOOKS']['updatePersonalData'][] = ['Oveleon\ContaoMemberExtensionBundle\Member', 'updateAvatar'];
26 36
 
27 37
 // Style sheet
28
-if (TL_MODE == 'BE')
38
+$request = System::getContainer()->get('request_stack')->getCurrentRequest();
39
+
40
+if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request))
29 41
 {
30 42
     $GLOBALS['TL_CSS'][] = 'bundles/contaomemberextension/style.css|static';
31 43
 }