Jump to content

Suggestion: Hooks Improvement


Recommended Posts

I'm back to make another totally unreasonable request! 😛

as you might know, some of us dev's use dirty taboo things called IDE's, and love their totally useless features like automatic imports, autocomplete/suggestions/etc. 

the issue i have and would love to see improved, is a slight tweak to the hook system, to allow me to better generate proxy files. currently you use _HOOK_CLASS_, which is great cause it doesn't toss errors up in the IDE, however, they all get this, so there is no easy way to generate a proxy file for _HOOK_CLASS_. I can easily generate them, but the problem becomes my IDE complains about multiple definitions and then throws its hands up in futility and tells me to GTFO. 

My suggestion would be to psuedo namespace hook, i believe this can be achieved with extremely limited intrusion to the existing code and remain backwards compatible.


allow me to append the hooks class to _HOOKS_CLASS_.

filename: BrandonMakeThisHappen.php



/* To prevent PHP errors (extending class does not exist) revealing path */

if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )

class myapp_hook_BrandonMakeThisHappen extends _HOOK_CLASS_myapp_hook_BrandonMakeThisHappen
    protected static function baseJs()
        Output::i()->jsFiles = array_merge(

and then in the init.php line 457 change:

$contents = "namespace {$namespace}; ". str_replace( '_HOOK_CLASS_', $realClass, file_get_contents( ROOT_PATH . '/' . $data['file'] ) );


$contents = "namespace {$namespace}; ". str_replace( array( '_HOOK_CLASS_', '_HOOK_CLASS_'.$data['class'] ), $realClass, file_get_contents( ROOT_PATH . '/' . $data['file'] ) );

this way either are replaced at runtime, backwards compatibility is maintained, and it requires hardly nothing to implement! it is the best of both worlds really, ones who don't use useless IDE's will never notice a difference, and the heathens that do, will be thankful! 

so @Daniel F @bfarber @Lindy (you guys need code names, lindy is the only one that is easy to find in the @mentions list!), lets make this happen! 🙂 

Link to comment
Share on other sites


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

  • Recently Browsing   0 members

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