我需要对Typo3扩展做一些改进,并对ObjectStorage有疑问。
TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage
的属性为$parentObject
和$fieldValue
。两者都受到保护,类中没有定义getter。
有没有办法访问这些属性?
我想要实现的目标:
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
}
数据库中的相应列包含整数值,Model类中的属性是ObjectStorage。我对该对象不感兴趣,但是在整数值中。
初始化ObjectStorage并填充后,属性已存在,但无法访问。
怎么办?感谢您的投入。
答案 0 :(得分:0)
LazyObjectStorage
扩展了\TYPO3\CMS\Extbase\Persistence\ObjectStorage
,此类实现了\Countable
,因此您只需使用count($this->readers)
来获取大小。