我再一次遇到了让类映射在Pimcore 4中工作的问题,这一次我想扩展文档页面类。这在老版本中可以正常工作,但是现在我不能让它工作了。
我从classmap.example.php用classmap.php复制了这个示例:
网站/config/classmap.php:
return [
"Document\\Page" => "Website\\Model\\Document\\Page",
]website/models/Website/Model/Document/Page.php:
namespace Website\Model;
use Pimcore\Model\Document;
class Page extends Document\Page {
public function getPublicPath() {
return $this->getFullPath();
}
}预期的结果是我可以在每个document\page对象上调用getPublicPath()。但这是行不通的。相反,我得到以下错误:
Call to undefined method getPublicPath in class Pimcore\Model\Document\Page我该如何让它工作呢?
发布于 2016-06-27 23:06:39
您的命名空间声明错误。它应该是:
namespace Website\Model\Document;所以整个类看起来是这样的:
<?php
namespace Website\Model\Document;
use Pimcore\Model\Document;
class Page extends Document\Page {
public function getPublicPath() {
return $this->getFullPath();
}
}在更新代码后,不要忘记清除缓存!
https://stackoverflow.com/questions/38055314
复制相似问题