lexik / LexikTranslationBundle

This Symfony bundle allow to import translation files content into the database and provide a GUI to edit translations.
MIT License
419 stars 255 forks source link

Symfony 6 Support #412

Closed tuxes3 closed 2 years ago

raziel057 commented 2 years ago

In this PR you need to change the composer.json to target only "php": "^8.0" as you use the syntax not compatible with php 7.4.

Maybe it could be more appropriate to first fix the deprecation for Symfony 5.4 while keeping compatibility with php 7.4. I will try to provide a PR for this this week.

raziel057 commented 2 years ago

To keep compatibility with PHP 7.4, please replace the constructor properties with explicit properties:

In RestController:

    private $dataGridRequestHandler;

    private $dataGridFormatter;

    private $translationStorage;

    private $transUnitManager;

    private $csrfTokenManager;

    public function __construct(
        DataGridRequestHandler $dataGridRequestHandler,
        DataGridFormatter $dataGridFormatter,
        StorageInterface $translationStorage,
        TransUnitManagerInterface $transUnitManager,
        ?CsrfTokenManager $csrfTokenManager
    ) {
        $this->dataGridRequestHandler = $dataGridRequestHandler;
        $this->dataGridFormatter = $dataGridFormatter;
        $this->translationStorage = $translationStorage;
        $this->transUnitManager = $transUnitManager;
        $this->csrfTokenManager = $csrfTokenManager;
    }

In RestController:

    private $translationStorage;

    private $statsAggregator;

    private $tokenFinder;

    private $transUnitFormHandler;

    private $lexikTranslator;

    private $translator;

    private $localeManager;

    private $csrfTokenManager;

    public function __construct(
        StorageInterface $translationStorage,
        StatsAggregator $statsAggregator,
        TokenFinder $tokenFinder,
        TransUnitFormHandler $transUnitFormHandler,
        Translator $lexikTranslator,
        TranslatorInterface $translator,
        LocaleManagerInterface $localeManager,
        ?CsrfTokenManager $csrfTokenManager
    ) {
        $this->translationStorage = $translationStorage;
        $this->statsAggregator = $statsAggregator;
        $this->tokenFinder = $tokenFinder;
        $this->transUnitFormHandler = $transUnitFormHandler;
        $this->lexikTranslator = $lexikTranslator;
        $this->translator = $translator;
        $this->localeManager = $localeManager;
        $this->csrfTokenManager = $csrfTokenManager;
    }
tuxes3 commented 2 years ago

To keep compatibility with PHP 7.4, please replace the constructor properties with explicit properties:

@raziel057 done. if you see anything else let me know.

raziel057 commented 2 years ago

@tuxes3 Thanks, you also need to remove some typehints for input parameters in Translation/Loader/DatabaseLoader::load and DatabaseFreshResource::isFresh

Please note that I encountered another issue while trying to install assets (with no database configured) https://github.com/lexik/LexikTranslationBundle/pull/413/files#diff-e91f9cbc1f9ca00ef52a75ff8bd64278333bc5a9c3199649b741578803b82875

I created a new PR taking your changes with the fixes here https://github.com/lexik/LexikTranslationBundle/pull/413

bartmcleod commented 2 years ago

Closing this because #413 was merged. If something was missed, let me know. I still have issues with SF 6.0.9 though, trying to fix those.