Skip to content

Commit 273bfe2

Browse files
committed
[BUGFIX] Set correct autoconfigure for ProcessingInstruction
During testing in another extension, it showed up, that `ProcessingInstruction` was not configured correctly. Change the autoload for this class and adopt all other classes using php attributes instead of registration via `Services.yaml`. With this change the autoload is made on the class, where it is needed and reduces the code inside the `Services.yaml` to the minimum.
1 parent db52057 commit 273bfe2

19 files changed

+93
-64
lines changed

Classes/Client.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
use DeepL\TextResult;
1313
use DeepL\TranslateTextOptions;
1414
use DeepL\Usage;
15+
use Symfony\Component\DependencyInjection\Attribute\AsAlias;
1516
use WebVision\Deepltranslate\Core\Exception\ApiKeyNotSetException;
1617

1718
/**
1819
* @internal No public usage
1920
*/
21+
#[AsAlias(id: ClientInterface::class, public: true)]
2022
final class Client extends AbstractClient
2123
{
2224
/**

Classes/Controller/Backend/AjaxController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@
66

77
use Psr\Http\Message\ServerRequestInterface;
88

9+
use TYPO3\CMS\Backend\Attribute\Controller;
910
use TYPO3\CMS\Core\Http\JsonResponse;
1011
use WebVision\Deepltranslate\Core\Configuration;
1112

12-
// @todo use #[Controller] if 12.4+ only support is established, see: TYPO3\CMS\Backend\Attribute\Controller;
13+
/**
14+
* Controller for fetching the DeepL settings via Ajax route for usage in JavaScript inside the backend
15+
*
16+
* Configured backend ajax route: deepl_check_configuration
17+
*
18+
* @internal No public API
19+
*/
20+
#[Controller]
1321
final class AjaxController
1422
{
1523
private Configuration $configuration;

Classes/Domain/Dto/CurrentPage.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace WebVision\Deepltranslate\Core\Domain\Dto;
66

7+
use Symfony\Component\DependencyInjection\Attribute\Exclude;
78
use WebVision\Deepltranslate\Core\Event\DeepLGlossaryIdEvent;
89

910
/**
@@ -14,8 +15,9 @@
1415
* detecting the right page,
1516
* for example, while detecting a glossary.
1617
*
17-
* @see DeepLGlossaryIdEvent for an usage example
18+
* @see DeepLGlossaryIdEvent for a usage example
1819
*/
20+
#[Exclude]
1921
final class CurrentPage
2022
{
2123
public function __construct(

Classes/Domain/Dto/TranslateContext.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44

55
namespace WebVision\Deepltranslate\Core\Domain\Dto;
66

7-
class TranslateContext
7+
use Symfony\Component\DependencyInjection\Attribute\Exclude;
8+
9+
/**
10+
* DTO providing the data shipped to DeepL translation.
11+
*/
12+
#[Exclude]
13+
final class TranslateContext
814
{
915
protected string $content = '';
1016

Classes/Form/Item/SiteConfigSupportedLanguageItemsProcFunc.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
namespace WebVision\Deepltranslate\Core\Form\Item;
66

77
use DeepL\Language;
8+
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
89
use WebVision\Deepltranslate\Core\Service\DeeplService;
910

10-
class SiteConfigSupportedLanguageItemsProcFunc
11+
/**
12+
* Adds DeepL related fields to the Site configuration
13+
*/
14+
#[Autoconfigure(public: true)]
15+
final class SiteConfigSupportedLanguageItemsProcFunc
1116
{
1217
private DeeplService $deeplService;
1318

Classes/Form/TranslationDropdownGenerator.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
*/
2424
final class TranslationDropdownGenerator
2525
{
26-
public function __construct()
27-
{
28-
}
29-
3026
/**
3127
* @param iterable<SiteLanguage> $siteLanguages
3228
* @throws \Doctrine\DBAL\Exception

Classes/Form/User/HasFormalitySupport.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44

55
namespace WebVision\Deepltranslate\Core\Form\User;
66

7+
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
78
use TYPO3\CMS\Backend\Form\FormDataProvider\EvaluateDisplayConditions;
89
use WebVision\Deepltranslate\Core\Service\DeeplService;
910

10-
class HasFormalitySupport
11+
/**
12+
* Checks a language having support for formality or not.
13+
*/
14+
#[Autoconfigure(public: true)]
15+
final class HasFormalitySupport
1116
{
1217
private DeeplService $deeplService;
1318

Classes/Hooks/AllowLanguageSynchronizationHook.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44

55
namespace WebVision\Deepltranslate\Core\Hooks;
66

7+
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
78
use TYPO3\CMS\Core\DataHandling\DataHandler;
89
use TYPO3\CMS\Core\Utility\MathUtility;
910

10-
class AllowLanguageSynchronizationHook
11+
/**
12+
* Changes the `l10n_state` for fields with allowLanguageSynchronisation enabled to custom.
13+
* This is required to allow overriding the translation.
14+
*/
15+
#[Autoconfigure(public: true)]
16+
final class AllowLanguageSynchronizationHook
1117
{
1218
public function processDatamap_beforeStart(DataHandler $dataHandler): void
1319
{
@@ -25,11 +31,7 @@ public function processDatamap_beforeStart(DataHandler $dataHandler): void
2531

2632
$columnConfig = $GLOBALS['TCA'][$table]['columns'][$column];
2733

28-
if (isset($columnConfig['config']['behaviour'])
29-
&& is_array($columnConfig['config']['behaviour'])
30-
&& isset($columnConfig['config']['behaviour']['allowLanguageSynchronization'])
31-
&& (bool)$columnConfig['config']['behaviour']['allowLanguageSynchronization'] === true
32-
) {
34+
if ((bool)($columnConfig['config']['behaviour']['allowLanguageSynchronization'] ?? false) === true) {
3335
$l10nState[$column] = (($columnConfig['l10n_mode'] ?? '') === 'prefixLangTitle')
3436
? 'custom'
3537
: 'parent';

Classes/Hooks/PageRendererHook.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44

55
namespace WebVision\Deepltranslate\Core\Hooks;
66

7+
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
78
use TYPO3\CMS\Core\Page\PageRenderer;
89

10+
/**
11+
* Adds the labels from deepltranslate_core to the backend, so they are available, as the default core functionality
12+
* is not working
13+
*/
14+
#[Autoconfigure(public: true)]
915
final class PageRendererHook
1016
{
1117
/**

Classes/Hooks/TranslateHook.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace WebVision\Deepltranslate\Core\Hooks;
66

7+
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
78
use TYPO3\CMS\Core\DataHandling\DataHandler;
89
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
910
use TYPO3\CMS\Core\Site\SiteFinder;
@@ -12,7 +13,11 @@
1213
use WebVision\Deepltranslate\Core\Exception\LanguageIsoCodeNotFoundException;
1314
use WebVision\Deepltranslate\Core\Exception\LanguageRecordNotFoundException;
1415

15-
class TranslateHook extends AbstractTranslateHook
16+
/**
17+
* The main translation rendering on localization.
18+
*/
19+
#[Autoconfigure(public: true)]
20+
final class TranslateHook extends AbstractTranslateHook
1621
{
1722
/**
1823
* @param array{uid: int} $languageRecord

0 commit comments

Comments
 (0)