[TYPO3-mvc] Extbase 1.3: initializeObject() changed?
Michael Knoll
mimi at kaktusteam.de
Wed Feb 2 17:26:07 CET 2011
Ok - just read your last line... in case of virtual attributes, create a
new function
protected function initVirtualAttributes() {
$this->bla = new...; // see last mail
}
and call it as well from the __construct() as from initializeObject()
should help!
Greetings
Michael
Am 02.02.11 12:17, schrieb roberto blanko:
> Hello devs,
>
> in my current Extbase extensions, I use initializeObject() in my models to
> init attributes, especially ObjectStorages for related objects.
>
> Since the Update to TYPO3 4.5 and therefore Extbase 1.3, I continuesly
> encounter PHP errors of the following type:
>
> Fatal error: Call to a member function attach() on a non-object
>
> This happens when I try to attach on object to an attribute that is beeing
> initialized as Tx_Extbase_Persistence_ObjectStorage. However in many cases
> the attribute remains NULL and the error above is thrown. It seems to me as
> if initializeObject() is not called every time the domain object is being
> created.
>
> $this->virtualChildren = new Tx_Extbase_Persistence_ObjectStorage();
>
> This is how my initializeObject() looks like:
>
> public function initializeObject()
> {
> parent::initializeObject();
> $this->children = new Tx_Extbase_Persistence_ObjectStorage();
> }
>
> Important notice: The attribute is not being persisted to a database. It's
> just a virtual attribute which contains values during runtime only.
>
> Regards
> roberto
More information about the TYPO3-project-typo3v4mvc
mailing list