[TYPO3-mvc] Mapping of none extbase tables like pages, tt_content,

Gianluca Strafella gianluca.strafella at webformat.com
Thu Mar 20 09:13:16 CET 2014


Hi Stefan,
Andreas is right. You should map property via TS only if the properties 
in your model don't respect naming conventions.
It's only needs build your Model and define all properties for it (uid 
and pid are implicit properties and you shouldn't define its in your 
Domain Model).

Your Model must extend \TYPO3\CMS\Extbase\DomainObject\AbstractEntity 
(in TYPO3 4.5 abstract class is names as 
Tx_Extbase_DomainObject_AbstractEntity) or AbstractValueObject if your 
model is a ValueObject.

You must map properties properly, respecting property type (f.e. 
\string) and using PHP annotations.

If you need property bodytext (about tt_news), you only need define 
property in your Domain Model as:


/**
   * This is property mapping in your model for the tt_news property 
bodytext
   *
   * @var \string
   */
protected $bodytext;


and accessor methods:

/**
  * Returns the bodytext
  *
  * @return \string $bodytext
  */
public function getBodytext() {
	return $this->bodytext;
}

/**
  * Sets the bodytext
  *
  * @param \string $bodytext
  * @return void
  */
public function setBodytext($bodytext) {
	$this->bodytext = $bodytext;
}



Here useful infos:

http://docs.typo3.org/typo3cms/ExtbaseFluidBook/5-Domain/2-implementing-the-domain-model.html

Regards,

Gianluca Strafella

Software Developer
gianluca.strafella at webformat.com

WEBFORMAT srl – www.webformat.com


Il 19/03/2014 19:57, Andreas Kiessling ha scritto:
> Hi,
>
>>
>> columns {
>> 	uid.mapOnProperty = uid
>> 	pid.mapOnProperty = pid
>> }
>>
>> needed.
>>
>> For tt_content and tt_address I have to do this. IF I only make a model for
>> tt_content or tt_address and only map it with tableName = tt_content than it
>> doesn't work. Only if I make the columns mapping.
>>
>> That's I wonder why It works by fe_users and by tt_content not.
>>
>
> if you have to map uid and pid, then there must be some error.
> You only have to do column mapping, if the field does not match the
> model property when passing it through "underscoredToLowerCamelCase"
>
> Thats my working config:
>
> config.tx_extbase.persistence.classes.Vendor\Extension\Domain\Model\TtContent.mapping
> {
>      tableName = tt_content
>      columns {
>          colPos.mapOnProperty = colPos
>          CType.mapOnProperty = CType
>      }
> }
>
> HTH,
> Andreas
>


More information about the TYPO3-project-typo3v4mvc mailing list