![](/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.