Reputation: 2904
I have the domain models Basket and Article. If I call the following I receive the articles in the basket.
$articlesInBasket = $basket->getArticles();
How can I use the TYPO3 standard attributes like crdate and cruser_id. It would be nice to use something like this:
$basket->getCrUser();
$basket->getCrDate();
Upvotes: 7
Views: 11603
Reputation: 1203
This works in TYPO3 8.7 and 9.5
model:
/**
* @var \DateTime
*/
protected $crdate = null;
/**
* Returns the creation date
*
* @return \DateTime $crdate
*/
public function getCrdate()
{
return $this->crdate;
}
TCA -> add this in the colums;
'columns' => [
'crdate' => [
'config' => [
'type' => 'passthrough',
],
],
...
]
Upvotes: 18
Reputation: 55798
First, the table fields are named as crdate
, and cruser
so getters should be named getCrdate
and get getCruser
Next in your model you need to add a field and a getter:
/** @var int */
protected $crdate;
/**
* Returns the crdate
*
* @return int
*/
public function getCrdate() {
return $this->crdate;
}
(do the same with cruser
field)
And finally in you setup.txt
most probably you'll need to add a mappings for these fields:
config.tx_extbase.persistence.classes {
Tx_Someext_Domain_Model_Somemodel {
mapping {
columns.crdate.mapOnProperty = crdate
columns.cruser.mapOnProperty = cruser
}
}
}
Of course, don't forget to use proper names in the settings, and clear the cache after changes in the code
Upvotes: 7
Reputation: 5122
This works for me with TYPO3 6.2.11
model:
/**
* tstamp
*
* @var int
*/
protected $tstamp;
/**
* @return int $tstamp
*/
public function getTstamp() {
return $this->tstamp;
}
TS:
config.tx_extbase.persistence.classes {
STUBR\Stellen\Domain\Model\Institution {
mapping {
tableName = tx_stellen_domain_model_institution
columns {
tstamp.mapOnProperty = tstamp
}
}
}
}
PS Thanks https://github.com/castiron/cicbase
Upvotes: 6