Minor "PHP Framework" 6. Proxy, minorphp framework Agent _php Tutorial

Source: Internet
Author: User
Tags php framework

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.