【问题标题】:Calling method parent class of extension parent class in SilverStripeSilverStripe中扩展父类的调用方法父类
【发布时间】:2019-07-24 14:03:01
【问题描述】:

我正在从事 SilverStripe 项目。我现在要做的是我试图调用扩展类的父类的方法。

我有这样的课

Order extension GenericOrder {
   public function validate()
   {
      $result = parent::validate(); 
      //Some other code
   }
}

然后我为它创建了一个扩展类

class OrderExtension extends DataExtension
{
    public function validate()
    {
        //here I want to call the validate method of the GenericOrder class
    }
}

正如您在评论中看到的那样,我正在尝试调用 GenericOrder 类的 validate 方法,该类是我的扩展类 OrderExtension 类试图扩展的 Order 类的父类。我怎么称呼它?

【问题讨论】:

    标签: silverstripe


    【解决方案1】:
    $this->owner->validate();
    

    【讨论】:

    • $this->owner 是我要扩展的类。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-14
    • 2012-02-11
    • 2018-02-24
    • 1970-01-01
    • 1970-01-01
    • 2019-05-18
    相关资源
    最近更新 更多