![](/img/trans.png)
[英]How can I exclude Taxes From a custom COD Surcharge in WooCommerce?
[英]How can i surcharge a connection configuration from a controller in Lithium?
我正在構建一個 GooglePlaces API,它是 package 作為 http 數據源。
我認為將它與基本的Places
model 和基本的gplaces
連接一起提供是個好主意,這樣數據源就可以在我的應用程序PlacesController
中開箱即用地使用:
use app\models\Places;
use google\models\Places as GPlaces;
class PlacesController extends \lithium\action\Controller { ... }
但我希望能夠以某種方式使用 API 密鑰對插件默認連接gplaces
進行附加。
試過:
GPlaces::config(array(
'key' => '<private_api_key>'
));
但它不會影響(正如我們所料)的連接,
有任何想法嗎?
在這種情況下, GPlaces
是 model,所以這樣做只會將該鍵分配給模型的配置,這不是您想要的。
如果您有一個名為'gplaces'
的連接,則應使用Connections::add()
中的該鍵對其進行配置,然后您可以告訴 model 使用該連接,如下所示:
GPlaces::config(array(
'connection' => 'gplaces'
));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.