Jump to content
  • [Beta 5] All stubs for listeners are missing the functions list


    Until beta 4 the listener stubs had a list of methods we could use. In beta 5 you added a use statement for IPS\Db but removed all methods.

    Any specific reason why you removed them? 🙄

     

    This is InvoiceListenerType.txt from beta :

    namespace IPS\{app}\listeners;
    
    /* To prevent PHP errors (extending class does not exist) revealing path */
    
    use IPS\Db;
    use IPS\Events\ListenerType\InvoiceListenerType;
    use IPS\Member as MemberClass;
    use IPS\nexus\Invoice as InvoiceClass;
    use function defined;
    
    if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
    {
    	header(($_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0') . ' 403 Forbidden');
    	exit;
    }
    
    /**
     * Invoice Listener
     */
    class {filename} extends InvoiceListenerType
    {
    
    }

     

    This is the same file from beta 4:

    namespace IPS\{app}\listeners;
    
    /* To prevent PHP errors (extending class does not exist) revealing path */
    
    use IPS\Events\ListenerType\InvoiceListenerType;
    use IPS\Member as MemberClass;
    use IPS\nexus\Invoice as InvoiceClass;
    use function defined;
    
    if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
    {
    	header(($_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0') . ' 403 Forbidden');
    	exit;
    }
    
    /**
     * Invoice Listener
     */
    class {filename} extends InvoiceListenerType
    {
    	/**
    	 * Fired when the invoice status is changed (e.g. unpaid to paid)
    	 *
    	 * @param InvoiceClass $invoice
    	 * @param string $status	The new status
    	 * @return void
    	 */
    	public function onStatusChange( InvoiceClass $invoice, string $status ) : void
    	{
    
    	}
    
    	/**
    	 * Fired when a member is created by an invoice.
    	 *
    	 * @param InvoiceClass $invoice
    	 * @param MemberClass $member    The new member
    	 * @param array $guestData  The original values of InvoiceClass::$guest_data
    	 * @return void
    	 */
    	public function onCreateAccountForGuest( InvoiceClass $invoice, MemberClass $member, array $guestData ) : void
    	{
    
    	}
    
    	/**
    	* Fired at each checkout step (before submission)
    	*
    	* @param InvoiceClass $invoice
    	* @param string $step   The checkout step (customer|pay)
    	* @return void
    	*/
    	public function onCheckout( InvoiceClass $invoice, string $step ) : void
    	{
    
    	}
    }

    User Feedback

    Recommended Comments

    Daniel F

    Posted

    I wanted them to be removed!

     

    The reason is very simple: Backwards compatibility!

    Image this scenario (which we literally had while the beta phase):

    Your app has an extension which implements a method from an extension and we change the signature because of a bug or code improvement ... What's going to happen? ALL 3rd party apps implementing the changed extension will cause issues because of the changed signature.
    What if you don't even need a changed method? It's still going to cause issues because of the empty method stub in your extension file.

    Now with the change, only the methods one needs will be implemented, which lowers the risk that it's going to break something if a signature changes.

    Let's be honest, all (most?) of the extension classes have an abstract base with all the methods, so a proper IDE will show you already all the available methods.

    It's a change which probably causes you 1-2 more clicks while developing your 3rd party stuff, but which will save the clients, us and the 3rd party devs a lot support and maintenance work later:) 

    teraßyte

    Posted

    I would still have left them there but all commented possibly.

     

    Oh well, just some more copy/paste work for us in the future. 😋

    Daniel F

    Posted

    Not a fan of the "Choose Methods to implement/override" feature? 

    CleanShot 2024-11-19 at 16.34.19.png

    teraßyte

    Posted (edited)

    Hmm, the shortcut for it doesn't work. Maybe it's because I'm using a really old version of phpStorm...

    I  should really update to the latest version. 👀

     

    EDIT: Oh, found the issue. Somehow the shortcut for it was empty. Not sure when or how it happened but it works now. I should really update to the latest version anyway. 🤦‍♂️

    Edited by teraßyte

×
×
  • Create New...