silverstripe / silverstripe-proxy-db
此包已废弃,不再维护。未建议替代包。
2.0.0
2023-04-03 22:12 UTC
Requires
README
这是一个从 tractorcow/silverstripe-proxy-db
分支出来的版本,在等待稳定的CMS 5发布并被标记到该存储库期间使用。该存储库现在已标记为稳定,因此您应该使用该版本而不是这个。
数据库代理
好的,您想代理数据库。
安装此模块,并用您想要扩展的代码装饰工厂
--- Name: myproxydb After: '#proxydb' --- TractorCow\SilverStripeProxyDB\ProxyDBFactory: extensions: - ProxyDBExtension
然后在您的代码中,您可以这样做
<?php use SilverStripe\Core\Extension; use TractorCow\ClassProxy\Generators\ProxyGenerator; class ProxyDBExtension extends Extension { public function updateProxy(ProxyGenerator &$proxy) { $proxy = $proxy->addMethod('manipulate', function ($args, $next) { SearchManipulator::manipulate($args[0]); return $next(...$args); }); } }
您可以链式调用方法;相同方法名称的所有 addMethod() 调用将形成一个中间件集。首先注册的方法首先执行。