• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I pass a parameter to a hook in CodeIgniter?

#1
In CodeIgniter, how can I pass parameters from the context where the hook is called?

Example:

File_Where_Hook_is_Called.php:

PHP Code:
    $this->hooks load_class('Hooks''core');

    $filename 'example.zip';

    $this->hooks->call_hook('site_export_before_delete'); 


config/hooks.php:


PHP Code:
    $hook['site_export_before_delete'][] = array(
            'class'    => 'Foo',
            'function' => 'export_site',
            'filename' => 'Foo.php',
            'filepath' => 'modules/foo/controllers',
            'params'   => [''# Should be $filename from File_Where_Hook_is_Called.php
    ); 


application/modules/foo/controllers/Foo.php:


PHP Code:
    public function export_site($filename) {
        echo $filename); # Should print $filename from File_Where_Hook_is_Called.php
    
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.