0
試圖擴展現有的插件組件 需要增加一個功能,但使用插件的方法調用組件提供了一個錯誤
這裏什麼我:
<?php namespace Bbrand\Shop\Components;
use Cms\Classes\ComponentBase;
use Jiri\JKShop\Components\Basket;
class Shopextend extends ComponentBase
{
public function componentDetails()
{
return [
'name' => 'shopextend Component',
'description' => 'No description provided yet...'
];
}
public function defineProperties()
{
return [];
}
public function onBasket(){
$data = [];
$data["basket"] = Basket::getSessionBasket();
$data["jkshopSetting"] = \Jiri\JKShop\Models\Settings::instance();
return [
$this->property("idElementWrapperBasketComponent") => $this->renderPartial('@basket-0', $data)
];
}
}
但我發現了一個錯誤
「應靜態調用非靜態方法Jiri \ JKShop \ Components \ Basket :: getSessionBasket()」,位於/Applications/MAMP/htdocs/fidgycube.co/plugins/bbrand/shop/components的第30行/Shopextend.php
任何幫助!? 謝謝
調用static =='::',在這種情況下並不意味着' - >' – Xorifelse
所以我該怎麼稱呼它? – aleXela
答案應該是盯着你,即使沒有我的評論...這是PHP OOP的基礎知識。 '$ data [「basket」] = Basket :: getSessionBasket();'被靜態調用,錯誤信息明確指出**不能**。現在閱讀我的第一條評論。 – Xorifelse