Jump to content

How do we extend functionality contained within traits?


Go to solution Solved by Lindy,

Recommended Posts

2 hours ago, HeadStand said:

You CAN hook into it, as long as it's on a specific class. Meaning, you can hook into \IPS\forums\Topic, just not \IPS\Content\Reactable. Is that not sufficient for what you're doing?

 

Yeah, I can hook into specific classes but not the main one. For example I want to make all apps not save a point for the chosen reputation under certain circumstances. I'd have to go around making an hook on each class for each application I want to support. And I just can't go around adding support for any 3rd party apps 1 by 1. I could do it, but I won't. I'll use my time in better ways 🙂

Link to comment
Share on other sites

25 minutes ago, teraßyte said:

Yeah, I can hook into specific classes but not the main one. For example I want to make all apps not save a point for the chosen reputation under certain circumstances. I'd have to go around making an hook on each class for each application I want to support. And I just can't go around adding support for any 3rd party apps 1 by 1. I could do it, but I won't. I'll use my time in better ways 🙂

have you tried telling the class to use the class method instead of the traits method? like:

trait FooTrait {
	public function bar(){
		return "hello, i'm a trait method!";
	}
}
class myhook extends HOOK_TEMP
{
	use FooTrait {
		bar as traitBar;
	}

	public function bar()
	{
		return "I am not the trait method!";
	}
}

i haven't tested this, but i can think of a potential problem or two. 

Link to comment
Share on other sites

  • 1 year later...
 Share

  • Recently Browsing   0 members

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