PHP code example of liquidlight / typo3-elevate-to-admin
1. Go to this page and download the library: Download liquidlight/typo3-elevate-to-admin library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
liquidlight / typo3-elevate-to-admin example snippets
namespace MyVendor\MyExtension\EventListener;
use LiquidLight\ElevateToAdmin\Event\BeforeAdminElevationProcessEvent;
use LiquidLight\ElevateToAdmin\Traits\AdminElevationTrait;
use TYPO3\CMS\Core\Core\Environment;
final class DevModeAdminListener
{
use AdminElevationTrait;
public function __invoke(BeforeAdminElevationProcessEvent $event): void
{
if (Environment::getContext()->isDevelopment()) {
$user = $event->getBackendUser();
// Make user admin if they can elevate and aren't already admin
if ($this->canUserElevate($user) && !$user->isAdmin()) {
$this->setAdminElevation((int)$user->user['uid']);
}
// Skip normal processing since we've handled it
$event->skipProcessing();
}
}
}