[TYPO3-mvc] Fatal error: Cannot access private property in AbstractDomainObject.php on line 260

g4-lisz at tonarchiv.ch g4-lisz at tonarchiv.ch
Mon Feb 16 23:49:37 CET 2015


Hi there,

is there no way to have variables in a model class for internal use only?

I have a variable:

    private $_last = NULL;


    public function getLast() {
        if ($this->_last == NULL) {

            /* some time consuming stuff */
        }
       
        return $this->_last;
    }

I do this because getLast gets called several times in one and the same
template.

Then I get the error:
Fatal error: Cannot access private property
XX\Domain\Model\BetriebRehaleistung::$_last in
/var/www/typo3_src-6.2.5/typo3/sysext/extbase/Classes/DomainObject/AbstractDomainObject.php
on line 260

Ok I can change private to protected. But why needs AbstractDomainObject
to access this property?

Even more strange is the fact that the same code works for other model
classes...

Cheers,
Till



More information about the TYPO3-project-typo3v4mvc mailing list