0
votes

I need to make some improvements to a Typo3-extension and have a question regarding the ObjectStorage.

TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage has the properties $parentObject and $fieldValue. Both are protected, no getter is defined in the class.

Is there any way to access the properties?

What I am trying to achieve:

class Topic extends AbstractEntity implements ... {
    /**
     * All users who have read this topic.
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Mittwald\Typo3Forum\Domain\Model\User\FrontendUser>
     * @lazy
     */
    protected $readers;

    public function __construct($subject = '') {
        // other stuff
        $this->readers = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
    }

    // more stuff
}

The corresponding column in the database holds an integer value, the property in the Model class is the ObjectStorage. I am not interested in the object, but in the integer value.

After initializing the ObjectStorage and populating, the properties are existing, but not accessible.

objectstorage::fieldvalue

What to do? Thanks for input.

1

1 Answers

0
votes

LazyObjectStorage extends \TYPO3\CMS\Extbase\Persistence\ObjectStorage and this class implements \Countable, so you can simply use count($this->readers) to get the size.