Franz Holzinger
Franz Holzinger

Reputation: 998

determine the TYPO3 version in migrations classes for the composer

The TYPO3 version must be determined in the file ClassAliasMapResult.php of an extension, because more than one version of TYPO3 must be supported by this extension. TYPO3 has the constant TYPO3_version for this. This alias mapping is needed in order to run TYPO3 extensions under several versions of TYPO3 with the same PHP code. The class alias mapping file depends on the version of TYPO3, because each of them has some differences in the names and numbers of the class files.

I have this file /Migrations/Code/ClassAliasMapResult.php in extension div2007 line 940:

if (version_compare(TYPO3_version, '8.0.0', '>=')) {
 $variantClassArray = array(
    'Tx_Aboutmodules_Controller_ModulesController' => \TYPO3\CMS\About\Controller\ModulesController::class,

However on some environments based on composer this raises an exception.

[ErrorException]
Use of undefined constant TYPO3_version - assumed 'TYPO3_version'

How can the constant TYPO3_version be made working for the composer autoloader as well?

Upvotes: 1

Views: 1049

Answers (2)

Wolffc
Wolffc

Reputation: 1250

i would sugesst to implement an "unversal Adapter" class which works on all TYPO3 Versions and from there detect the current TYPO3 version. and load the concrete implementation for the current TYPO3 version.

and not use the class alias map for such magic.

Upvotes: 0

helhum
helhum

Reputation: 463

This file must in all cases be treated as simple hash map. No other PHP code must be added to this file.

If you have a case where you think you need PHP code in this file, then this case cannot be covered with the class alias map concept.

Upvotes: 2

Related Questions