[TYPO3-mvc] Magic Getters and Setters for AbstractDomainObject

Philipp philippwrann at gmx.at
Fri Oct 25 08:48:08 CEST 2013


I think a fallback for the magic method is definitly a way to do it.

So if a setter is present it is used, you can use your IDEs autocompletion have better controll over the process, but if its just a very simple model in a little extension it would be nice to just have this filestructure

/**
 * @fluent
 */
Model Test extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
/** @var string */
public $name;
/** @var \Vendor\Extenssion\Domain\Model\FileReference */
public $image;
/** @var string */
public $text;
}

A method __set($p,$v);

checks:
is there a accessible setUCFIRST(p) method? -> return method-call
is there a accessible property? -> cast/set via reflection  | return (class is fluent ? self : void)
throw exception;

So you could define such a simple model structure + set it like
$model->setImage($image)->setTitle($title)->setText($text);

A magic getter would not be neccessary, so performance in the frontend is not worse, maybe slightly better instead.

I dont see the reason why this would be so bad, but it would definitly be a nice-to-have.


More information about the TYPO3-project-typo3v4mvc mailing list