|
| 1 | +<?php |
| 2 | +declare(strict_types = 1); |
| 3 | +namespace FriendsOfTYPO3\SudoMode\Backend; |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is part of the TYPO3 CMS project. |
| 7 | + * |
| 8 | + * It is free software; you can redistribute it and/or modify it under |
| 9 | + * the terms of the GNU General Public License, either version 2 |
| 10 | + * of the License, or any later version. |
| 11 | + * |
| 12 | + * For the full copyright and license information, please read the |
| 13 | + * LICENSE.txt file that was distributed with this source code. |
| 14 | + * |
| 15 | + * The TYPO3 project - inspiring people to share! |
| 16 | + */ |
| 17 | + |
| 18 | +use TYPO3\CMS\Backend\LoginProvider\UsernamePasswordLoginProvider; |
| 19 | +use TYPO3\CMS\Core\Page\PageRenderer; |
| 20 | +use TYPO3\CMS\Core\Utility\GeneralUtility; |
| 21 | +use TYPO3\CMS\Extbase\Object\ObjectManager; |
| 22 | +use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; |
| 23 | +use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; |
| 24 | + |
| 25 | +/** |
| 26 | + * Aims to adapt external services or extensions to be working with `ext:sudo_mode`. |
| 27 | + */ |
| 28 | +class ExternalServiceAdapter |
| 29 | +{ |
| 30 | + public function emitLoginProviderSignal(PageRenderer $pageRenderer = null): void |
| 31 | + { |
| 32 | + $this->getSignalSlotDispatcher()->dispatch( |
| 33 | + UsernamePasswordLoginProvider::class, |
| 34 | + UsernamePasswordLoginProvider::SIGNAL_getPageRenderer, |
| 35 | + [$pageRenderer ?? $this->getPageRenderer()] |
| 36 | + ); |
| 37 | + } |
| 38 | + |
| 39 | + public function getSignalSlotDispatcher(): Dispatcher |
| 40 | + { |
| 41 | + return $this->getObjectManager()->get(Dispatcher::class); |
| 42 | + } |
| 43 | + |
| 44 | + public function getObjectManager(): ObjectManagerInterface |
| 45 | + { |
| 46 | + return GeneralUtility::makeInstance(ObjectManager::class); |
| 47 | + } |
| 48 | + |
| 49 | + public function getPageRenderer(): PageRenderer |
| 50 | + { |
| 51 | + return GeneralUtility::makeInstance(PageRenderer::class); |
| 52 | + } |
| 53 | +} |
0 commit comments