[英]Silverstripe How to get datas in SiteConfig from subclasses
Actualy, i'm using this code from a extended class. 实际上,我正在使用扩展类中的这段代码。
Example : 范例:
class EcommerceEmail extends Email {
...
$from = SiteConfig::get()->first()->EcommerceDefaultEmail;
...
}
My problem here is the $from variable. 我的问题是$ from变量。 It's working, but I don't think this is the best idea.
它正在工作,但是我认为这不是最好的主意。
I have thinked this 我想过
$this->SiteConfig()->EcommerceDefaultEmail
Or this 或这个
$this->owner->SiteConfig()->EcommerceDefaultEmail
My last two code don't work and I don't know why. 我的最后两个代码不起作用,我也不知道为什么。 Is there another way to get EcommerceDefaultEmail in SiteConfig() from a subclass?
有没有另一种方法可以从子类中的SiteConfig()中获取EcommerceDefaultEmail?
You can use SiteConfig::current_site_config()
. 您可以使用
SiteConfig::current_site_config()
。 Eg. 例如。
SiteConfig::current_site_config()->EcommerceDefaultEmail
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.