我有一个扩展,可以设置这样的搜索字段:
public function onBeforeWrite()
{
parent::onBeforeWrite();
$this->getOwner()->SearchContent = $this->collateSearchContent();
}
除了仅在新页面或更新页面外,它工作正常。我想循环遍历 SiteTree 并保存每个的 SearchContent。
在我的任务中,我这样做:
foreach (SiteTree::get() as $item) {
$item->getOwner()->SearchContent = $item->getOwner()->collateSearchContent();
$item->write();
}
我收到错误:
Uncaught BadMethodCallException: Object->__call(): the method 'collateSearchContent' does not exist on 'WAIRC\BlockPage'
所以,快到了。但它没有使用 SiteTree 对象来查找该方法。如何访问 sitetree 对象?