Extbase - Mapping: Unterschied zwischen den Versionen
(Die Seite wurde neu angelegt: „Siehe auch http://wiki.zone30.info/wikizone/index.php/Extbase_-_Zugriff_auf_die_fe_user_Tabelle == Was ist Mapping == Mapping benötigt man immer dann, wenn…“) |
|||
| (Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
| Zeile 31: | Zeile 31: | ||
config.tx_extbase.persistence | config.tx_extbase.persistence | ||
machen. | machen. | ||
| + | |||
| + | |||
| + | ==Mapping mit Namespaces == | ||
| + | Eventuell bei OldSchool bleiben, da die Namespaces in den "alten" Teilen von Typo eh nicht weit integriert sind. | ||
| + | |||
| + | http://www.lacisoft.com/blog/2013/01/05/extbase-tablename-mapping-with-namespaces/ (2015-06) | ||
| + | Old School | ||
| + | <syntaxhighlight lang="typoscript"> | ||
| + | config.tx_extbase.persistence.classes { | ||
| + | Tx_MyExtension_Domain_Model_User { | ||
| + | mapping { | ||
| + | tableName = fe_users | ||
| + | columns { | ||
| + | first_name.mapOnProperty = firstName | ||
| + | name.mapOnProperty = name | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </syntaxhighlight> | ||
| + | Now with TYPO3 6.0 namespaces were introduced and your domain model uses them, in this case your mapping should look like this: | ||
| + | <syntaxhighlight lang="typoscript"> | ||
| + | config.tx_extbase.persistence.classes { | ||
| + | Vendor/MyExtension/Domain/Model/User { | ||
| + | mapping { | ||
| + | tableName = fe_users | ||
| + | columns { | ||
| + | first_name.mapOnProperty = firstName | ||
| + | name.mapOnProperty = name | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </syntaxhighlight> | ||
Aktuelle Version vom 25. Juni 2015, 17:05 Uhr
Siehe auch
http://wiki.zone30.info/wikizone/index.php/Extbase_-_Zugriff_auf_die_fe_user_Tabelle
Was ist Mapping[Bearbeiten]
Mapping benötigt man immer dann, wenn in Extbase Daten aus fremden Datenquellen bezogen werden. Z.B. wenn man aus einer eigenen Extension Daten aus fe_users oder tt_address nutzen möchte.
In deiner Extension hast du z.B. ein Model des Typs Person. Dafür möchtest du die bereits vorhandene Tabelle tt_address nutzen. Jetzt mußt du Extbase mitteilen welches Datenobjekt welchem Datenobjekt entspricht. Das kann man über TypoScript erledigen. Entweder nur für dein Extension Setup oder Global für alle Extensions.
Hier möchte ich z.B. die Property birthday auf das Feld dateOfBirth in tt_address mappen etc.
plugin.tx_myextension {
persistence {
classes {
Tx_MyExtension_Domain_Model_Person {
mapping {
tableName = tt_address
recordType = Tx_MyExtension_DomIn_Model_Person
columns {
birthday.mapOnProperty = dateOfBirth
street.mapOnProperty = thoroughfare
}
}
}
}
}
}
Global würde man das unter dem Schlüssel
config.tx_extbase.persistence
machen.
Mapping mit Namespaces[Bearbeiten]
Eventuell bei OldSchool bleiben, da die Namespaces in den "alten" Teilen von Typo eh nicht weit integriert sind.
http://www.lacisoft.com/blog/2013/01/05/extbase-tablename-mapping-with-namespaces/ (2015-06) Old School
config.tx_extbase.persistence.classes {
Tx_MyExtension_Domain_Model_User {
mapping {
tableName = fe_users
columns {
first_name.mapOnProperty = firstName
name.mapOnProperty = name
}
}
}
}
Now with TYPO3 6.0 namespaces were introduced and your domain model uses them, in this case your mapping should look like this:
config.tx_extbase.persistence.classes {
Vendor/MyExtension/Domain/Model/User {
mapping {
tableName = fe_users
columns {
first_name.mapOnProperty = firstName
name.mapOnProperty = name
}
}
}
}