Welcome Guest, Not a member yet? Register   Sign In
Hooks and Classes - do not require method name
#1

[eluser]drewbee[/eluser]
Hello,

I am currently working on writing a pre-system hook and want to use the class'es invoking constructor call as the only item that get executed, IE not defining a method to run as well. The constructor will run everything.

Is there any reason why this function argument is required?

hooks/referral.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Referral
{
    function __construct()
    {
         echo 'go get um';
    }
    function test()
    {
        echo 'test';
    }
}
?>

config/hooks.php
Code:
// Nope...
$hook['pre_system'] = array(
                                'class' => 'Referral',
                                'function' => '',
                                'filename' => 'referral.php',
                                'filepath' => 'hooks',
                                'params'   => array()
                                );

// nope either
$hook['pre_system'] = array(
                                'class' => 'Referral',
                                'filename' => 'referral.php',
                                'filepath' => 'hooks',
                                'params'   => array()
                                );

Both these examples above produce an error.
First: Fatal error: Call to undefined method Referral:Sad)

Second: 'method name must be a string'.

I guess at the very least I could create a returnFalse() method as the default method which will do nothing but return false.

Thoughts?




Theme © iAndrew 2016 - Forum software by © MyBB