Zum Inhalt springen

Erweiterung fe_users durch mehrere Extensions - Problem: recordType?!

Erstellt am 5. Mai 2015 · 1 Antwort · letzte Antwort am 6. November 2016

Tags: Frontend-Benutzer, Frage

iconomie ·

Hi zusammen,
ich stehe gerade vor dem Problem, dass ich 2 Extensions (TYPO3 6.2) habe, die beide die fe_users erweitern. Jetzt ist es aber so, dass Extension A den RecordType "Tx_A_FrontendUser" und Extension B "Tx_B_FrontendUser" benutzt. Je nachdem, wie ich beim User-Record den Type definieren, sehe ich im Backend auch die erweiterten Felder. Im Controller bekomme ich bei einem findAll() alle Nutzer mit recordType der aktuellen Extension geliefert, nicht aber der anderen Extension. Was durchaus so gewollt sein dürfte.

Wie schaffe ich es aber jetzt, dass beide Extensions den gleichen recordType nutzen und die erweiterten Felder beider Extensions im Backend angezeigt werden? Vielleicht stehe ich gerade auch nur komplett auf dem Schlauch...

Ich habe im Extension-Builder jew. ein Model "FrontendUser" angelegt:
- Mapping auf Tabelle: fe_users
- Extend Model Class: \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
- per TS folgende Einträge gesetzt:

config.tx_extbase.persistence.classes {
  TYPO3\CMS\Extbase\Domain\Model\FrontendUser {
    subclasses {
      tx_a = VENDOR\A\Domain\Model\FrontendUser
    }
  }

  VENDOR\A\Domain\Model\FrontendUser {
    mapping {
      tableName = fe_users
      recordType = 
    }
  }
}

plugin.tx_a {
  persistence {
    VENDOR\A\Domain\Model\FrontendUser {
      mapping {
        tableName = fe_users
        recordType = 
      }
    }
  }
}

Hat jemand einen Tipp für mich?

ursbraem ·

Einen Tipp nicht, aber eine ähnliche Frage. Konntest du was rausfinden hierzu?
Vermutlich nicht, oder? https://docs.typo3.org/typo3cms/extensions/extension_builder/Developer/ExtendingModels.html

Note

Restrictions for STI (Single table inheritance)

You should be aware, that the mapping to an existing table has some side effects: Extbase will store the model in the table. When it tries to restore the model, for example if a parameter tx_myext_myplugin[modelname]=23 is passed to a controller, it has to find the right subclass. This is implemented by a type field, which is the type field defined in $GLOBALS[TCA][my_table][ctrl][type]. But in many system table like pages or tt_content the type field is used for different purposes, for example the type field of tt_content holds the Content Type of the record and is used to find the right rendering definition for that record. Now, when you map your model to tt_content this will add a new type value which has no rendering definition at all.

Another issue related to single table inheritance is, that there is no real implementation in TYPO3 to avoid conflicts if multiple extensions extend the same model. If there are 3 extension which extend a news model, you have always to decide, which model you will use. You can't use the features of all subclasses in one model.

Caution

Do not use STI of external models in extensions you want to publish in TER. You (and the user who download your extension) have no control of how many other extensions try to extend the same model which will result in unexpected behaviour!