I'm trying to use a virtual domain model property in TYPO3 9.5.x that doesn't have a database field representation but I can't get it to work.
My model looks like this
class Project extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
/**
* participants
*
* @var string
*/
protected $participants;
...
/**
* Returns the participants
*
* @return string $participants
*/
public function getParticipants()
{
$this->participants = "foo";
return $this->participants;
}
}
I do see the property when I debug the model but it's always null
as if it doesn't even recognise the getter method getParticipants()
.
Any idea what I might be doing wrong?
Already added a database field to ext_tables.sql
and the TCA, but it didn't seem to make a difference.
The property is null
because that's the state when the Extbase debugger inspects it. Notice that the Extbase debugger knows nothing about getters and also does not call them.
So if you want to initialize your property you must do this at the declaration time:
protected $participants = 'foo';