Commit 9caf10ee authored by Christian Kuhn's avatar Christian Kuhn Committed by Oliver Bartsch
Browse files

[!!!][TASK] Remove extbase EnvironmentService

Resolves: #96159
Related: #92494
Releases: main
Change-Id: I330165bd268f9e9eb011b6ee5bee208f446aed6f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72403


Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent 696e5f29
......@@ -27,6 +27,7 @@ The following PHP classes that have previously been marked as deprecated for v11
- :php:`\TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository`
- :php:`\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository`
- :php:`\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository`
- :php:`\TYPO3\CMS\Extbase\Service\EnvironmentService`
The following PHP interfaces that have previously been marked as deprecated for v11 and were now removed:
......
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Extbase\Service;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\SingletonInterface;
/**
* Service for determining environment params
* @internal only to be used within Extbase, not part of TYPO3 Core API.
* @deprecated since v11.2, will be removed in v12.0.
*/
class EnvironmentService implements SingletonInterface
{
/**
* @var bool|null
*/
protected $isFrontendMode;
public function __construct()
{
trigger_error(__CLASS__ . ' will be removed in TYPO3 v12, use the PSR-7 Request and the ApplicationType instead.', E_USER_DEPRECATED);
}
/**
* Detects if frontend application has been called.
*
* @return bool
*/
public function isEnvironmentInFrontendMode(): bool
{
$this->initialize();
if ($this->isFrontendMode !== null) {
return $this->isFrontendMode;
}
// Frontend mode stays false if backend or cli without request object
return ($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
&& ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend();
}
/**
* Detects if backend application has been called.
*
* @return bool
*/
public function isEnvironmentInBackendMode(): bool
{
return !$this->isEnvironmentInFrontendMode();
}
protected function initialize(): void
{
if ($this->isFrontendMode !== null) {
return;
}
// Frontend mode stays false if backend or cli without request object
$this->isFrontendMode = ($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
&& ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend();
}
/**
* A helper method for tests to simulate application behavior, should only be used within TYPO3 Core
*
* @param bool $isFrontendMode
* @internal only used for testing purposes and can be removed at any time.
*/
public function setFrontendMode(bool $isFrontendMode): void
{
$this->isFrontendMode = $isFrontendMode;
}
}
......@@ -47,8 +47,6 @@ class ServiceProvider extends AbstractServiceProvider
Configuration\BackendConfigurationManager::class => [ static::class, 'getBackendConfigurationManager' ],
Configuration\ConfigurationManager::class => [ static::class, 'getConfigurationManager' ],
Reflection\ReflectionService::class => [ static::class, 'getReflectionService' ],
// @deprecated since v11, will be removed in v12
Service\EnvironmentService::class => [ static::class, 'getEnvironmentService' ],
Service\ExtensionService::class => [ static::class, 'getExtensionService' ],
Service\ImageService::class => [ static::class, 'getImageService' ],
Security\Cryptography\HashService::class => [ static::class, 'getHashService' ],
......@@ -97,14 +95,6 @@ class ServiceProvider extends AbstractServiceProvider
return self::new($container, Reflection\ReflectionService::class, [$container->get(CacheManager::class)->getCache('extbase'), $container->get(PackageDependentCacheIdentifier::class)->withPrefix('ClassSchemata')->toString()]);
}
/**
* @deprecated since v11, will be removed in v12
*/
public static function getEnvironmentService(ContainerInterface $container): Service\EnvironmentService
{
return self::new($container, Service\EnvironmentService::class);
}
public static function getExtensionService(ContainerInterface $container): Service\ExtensionService
{
$extensionService = self::new($container, Service\ExtensionService::class);
......
......@@ -1624,6 +1624,7 @@ return [
'TYPO3\CMS\Extbase\Service\EnvironmentService' => [
'restFiles' => [
'Deprecation-92494-ExtbaseEnvironmentService.rst',
'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
],
],
'TYPO3\CMS\Backend\ViewHelpers\ModuleLayoutViewHelper' => [
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment