[TYPO3-50-general] Helping Functions
Xavier Perseguers
typo3 at perseguers.ch
Mon Feb 2 13:18:11 CET 2009
Hi Sebastian,
>> Is there currently a way so I don't need to write all this set/get
>> functions?
> Currently (IMHO) we require you to write all getters / setters by hand.
> In the middle-long term, there will be scaffolding for that - but you
> should do that because the domain layer should not contain any "magic".
> When Eclipse supports namespace syntax, it'll be much nicer to work with
> if you have explicit getters/setters.
> If you, however, require a way to access getters/setters
> programmatically, we've created helpers in Reflection/ObjectAccess.php.
> This is a kind of Java Beans implementation for PHP.
I'm using the method shown on [1] for my current 4.x development. It
works very well and the interesting part is that it is similar than
public property:
$myobject->someProperty = "hello world!";
echo $myobject->someProperty;
instead of
$myobject->setSomeProperty("hello world!");
echo $myobject->getSomeProperty();
which I find better and similar to C#.
The overhead of the method shown in term of definition of private and
public fields that are then overriden at instantiation time is a bit
high though. But I would love to have such feature (enhanced of course)
in FLOW3.
[1] http://latrine.dgx.cz/property-setters-and-getters-final-solution
--
Xavier Perseguers
http://xavier.perseguers.ch/en/tutorials/typo3.html
More information about the TYPO3-project-5_0-general
mailing list