Minor "PHP Framework" 6. Proxy, minorphp framework Agent
6.1 Agents
Minor provides an implementation similar to the Invocationhandler interface in Java and a proxy class, which can be consulted in this article: http://www.cnblogs.com/orlion/p/5350752.html
6.1.1 Use
class extends controller{ publicfunction Bar ($productName) { $log New Loghandler (); $shop New Shop (); $shopProxy = proxy::newproxyinstance ($shop$log); $shopProxy->buy ($productName); }}
!--?
phpnamespace app\lib;
Use
minor\proxy\invocationhandler;
class Loghandler
implements
invocationhandler{
public
function invoke (
$target , \reflectionmethod
$method ,
Array
$args =
[]) {
$this ->
before ();
$result =
$method ->invokeargs (
$target ,
$args
) ;
$this ->
after ();
return
$result
;
public
function
before () {
echo ' [Loghandler] is Fore
'
;
public
function
after () {
echo ' [Loghandler] aft ER
'
; }}
Phpnamespace App\lib; class shop{ private$mailnull; Public function $mail { $thismail$mail; } Public function Buy ($productName) { echo$productName . '
'; ! Is_null ($thismail$this, mail->send (' DemoUser ');} }
http://www.bkjia.com/PHPjc/1135178.html www.bkjia.com true http://www.bkjia.com/PHPjc/1135178.html techarticle Minor "PHP framework" 6. Proxy, minorphp framework Proxy 6.1 Proxy Minor provides an implementation similar to the Invocationhandler interface in Java and a proxy class, specifically for reference ...