Some questions about hooks

melo lobo Posted in Beginning Developers 6 months ago

While trying to understand your impressive code, I noticed that the defined hooks are the following:

using this:

            echo '<pre>';
            echo '</pre>';
        [0] => load:settings
        [1] => user
        [2] => database
        [3] => css
        [4] => js
        [5] => newsfeed
        [6] => profile
        [7] => search
        [8] => wall:template
        [9] => notification:view
        [10] => wall
        [11] => required
        [12] => post
        [13] => notification:participants
        [14] => photo:view
        [15] => cover:view
        [16] => notification:add
        [17] => entities
        [18] => message
        [19] => group
        [20] => theme
        [21] => page
        [22] => comment:view

But how do we call a hook that is not defined with ossn_add_hook('ossn'...?" (ossn hook is not defined)

$hook = ossn_call_hook('ossn', 'input', false, array(
                'input' => $input,
                'noencode' => $noencode,
                'default' => $default,
                'strip' => $strip,
                'data' => $data_hook,

I tried to find 'ossn_add_hook('ossn','input'...' throughout the code, but it doesn't exist
(im on the ossn free version ).

ma Melo lobo Replied 6 months ago

OK I understand. thank you Arsalan

Indonesian Arsalan Shah Replied 6 months ago

It won't be set in global variable unless add hook function is used. call hook is just expecting the hook that doesn't mean it always exists. So when you add add hook it will get registered and then call hook can use it.

If no add hook (not registered in the variable you checking)
if add hook function utilized (it will exists)

If you add following in your component initialize function

ossn_call_hook('ossn', 'input', function($h, $t, $return, $params){
                     return $return;

Then check the result of variables again it will show it.

ma Melo lobo Replied 6 months ago

I didn't understand how you call a Hook that is not declared and does not exist on the variable $Ossn. I found this call that I didn't understand in the code of the input() function in the file ossn.lib.input.php. From what I understood, hooks are mainly defined in the ossn_com files by the ossn_add_hook(...) function and are called when needed by the ossn_call_hook(...) function. So, why in the code of the input function in the file ossn.lib.input.php did you call the 'ossn' hook that I can't find among the existing hooks in $Ossn? And I also can't find ossn_add_hook('ossn', 'input',...) which is supposed to define the Ossn hook

$hook = ossn_call_hook('ossn', 'input', false, array(
                'input' => $input,
                'noencode' => $noencode,
                'default' => $default,
                'strip' => $strip,
                'data' => $data_hook,
Indonesian Arsalan Shah Replied 6 months ago

What are you looking for?