Skip to content

Commit

Permalink
chore: code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
aoekrz committed Jul 3, 2024
1 parent 8cdf3c2 commit 7ba0c6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
4 changes: 4 additions & 0 deletions .code-quality/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ parameters:
message: "#^Interface (.*) has only single implementer. Consider using the class directly as there is no point in using the interface.$#"
count: 1
path: ../Classes/System/Restler/ConfigurationInterface.php
-
message: "#^Unable to resolve the template type T in call to method static method (.*)$#"
count: 2
path: ../Classes/System/Restler/Builder.php
28 changes: 3 additions & 25 deletions Classes/System/Restler/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

use Aoe\Restler\Configuration\ExtensionConfiguration;
use Aoe\Restler\System\TYPO3\Cache;
use Error;
use InvalidArgumentException;
use Luracast\Restler\Defaults;
use Luracast\Restler\Scope;
Expand All @@ -37,7 +36,6 @@
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;

class Builder implements SingletonInterface
{
Expand Down Expand Up @@ -139,32 +137,12 @@ private function addApiClassesByGlobalArray(RestlerExtended $restler): void
}

/**
* use auto-loading for PHP-classes of restler-framework and Extbase/TYPO3 (use dependency-injection of Extbase)
* use autoload for PHP-classes of restler-framework and Extbase/TYPO3 (use dependency-injection of Extbase)
*/
private function setAutoLoading(): void
{
// set auto-loading for Extbase/TYPO3-classes
Scope::$resolver = static function ($className) {
try {
return GeneralUtility::makeInstance($className);
} catch (Error $error) {
// @TODO TYPO3 v12:
// Using of ObjectManager will be removed in TYPO3v12. Currently, we must use the ObjectManager
// as a fallback because it can happen, that e.g. the REST-controllers (which 3rd-party-extensions
// provide), are not supporting the new dependency-injection (via symfony) of TYPO3!

// Log deprecation-notice
$info = '%s should implement TYPO3\CMS\Core\SingletonInterface - otherwise the class can ';
$info .= 'not be created by GeneralUtility::makeInstance() in TYPO3v12 (error-code: %s)!';
trigger_error(
sprintf($info, $className, (string) $error->getCode()),
E_USER_DEPRECATED
);

// use legacy ObjectManager to create the required object
return GeneralUtility::makeInstance(ObjectManager::class)->get($className);
}
};
// set autoload for Extbase/TYPO3-classes
Scope::$resolver = static fn ($className): object => GeneralUtility::makeInstance($className);
}

/**
Expand Down

0 comments on commit 7ba0c6a

Please sign in to comment.