Jump to content

How to extend function with \IPS\Output::i()


Tom S.

Recommended Posts

I'm creating a plugin to hook into a function to add some extra functionality.

 

class hook100 extends _HOOK_CLASS_
{
	protected function someFunc()
	{
    		$return = parent::clear();

          	// my code

          	return $return;
	}

}

The problem is that when parent::clear(); runs it contains a bunch of

\IPS\Output::i()->redirect()

Meaning that my code never gets executed as the page leaves before then. Does anyone have any advice how to handle situations like this?

Link to comment
Share on other sites

If you can run your code first then you can do something like

public function something()
{
	// Run my custom code

	return parent::something();
}

If not, then your only real options are:

  1. Copy the parent function's code and don't call parent, injecting your code where it needs to run
  2. Move your processing somewhere else. For instance, when working with content items there are a lot of callbacks that execute (like postCreate()) that would be a more appropriate place to run code after the item is created.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...