0
votes

what i am trying to achieve is to automate helpers loading scripts and css. So basically the idea is to have a function on every helper, which is loading scripts / styles to be used dedicated to the helper. I guess it can be achieved by having a controlling helper which is querying for all active helpers and then execute the script/style loading function.

What I cannot find in the documentation is:

  • How can a helper query the list of active helper objects
1

1 Answers

2
votes

You can query the HelperRegistry of the View using (see View::helpers):

$this->_View->helpers();

Once you have the registry, you can get the names of the loaded helper using HelperRegistry::loaded() and retrieve them using HelperRegistry::get():

// Inside your helper:
$registry = $this->_View->helpers();
foreach ($registry->loaded() as $name) {
    $helper = $registry->get($name);
}

Disclaimer: Code above not tested.