What happens if the parent method is called more than once?

RastaLulz

Well-known member
So I just created my first add-on, and while using load_class_* listeners, you have to call the parent method like so:
PHP:
<?php

class RastaLulz_LoggedInCookie_Model_User extends XFCP_RastaLulz_LoggedInCookie_Model_User
{
    public function setUserRememberCookie($userId, $auth = null)
    {
        $response = parent::setUserRememberCookie($userId, $auth);

        XenForo_Helper_Cookie::setCookie('logged_in', 1, 30 * 86400, true);

        return $response;
    }
}

My question is, what happens if two add-on's are listening for a specific method, and call the parent method? Does it get executed twice?
 
So I just created my first add-on, and while using load_class_* listeners, you have to call the parent method like so:
PHP:
<?php

class RastaLulz_LoggedInCookie_Model_User extends XFCP_RastaLulz_LoggedInCookie_Model_User
{
    public function setUserRememberCookie($userId, $auth = null)
    {
        $response = parent::setUserRememberCookie($userId, $auth);

        XenForo_Helper_Cookie::setCookie('logged_in', 1, 30 * 86400, true);

        return $response;
    }
}

My question is, what happens if two add-on's are listening for a specific method, and call the parent method? Does it get executed twice?

The xenforo class proxy prevents it from executing twice. AFAIK it makes all the classes extend each other before they extend the 'real' class. Though, I may be wrong. The parent definitely won't execute twice though :)
 
Back
Top Bottom