0
在我的插件的一個組件中,我有一個讀取用戶輸入的函數(使用Input::get()
),創建一個Model
並將其保存到數據庫。數據通過html表單提交給這個函數。現在我想讓用戶通過Rest API
添加新數據。所以我在我的插件的根目錄下創建了一個名爲routes.php
的文件,並定義了發佈數據的路徑。由於這是合乎邏輯的重用是我的插件組件已經提供的代碼,我試圖路由映射到已有的組件功能:如何使插件組件功能在OctoberCMS中作爲Rest API使用?
Route::post('/items', 'Acme\Plugin\Components\[email protected]');
但是,這並不工作,我得到以下錯誤:
The component Acme\Plugin\Components\ItemsList does not contain a method getAfterFilters
這是如何在Rest API中重用代碼?爲什麼我得到這個錯誤?
Acme \ Plugin \ Co mponents \ ItemsList實現了一些接口,並且你必須有一個getAfterFilters方法。或者不要從該界面實現。 – Asheliahut
@Asheliahut它擴展了'ComponentBase',就像OctoberCMS中的所有組件一樣。 – Meysam