Hello,
Should it be possible to load and use a custom helper function from within a controller filter?
I want to shortcut creating a Google API client object, the class for which is being auto-loaded by composer. I need the client in most controllers, but in the filter too for auth.
I have "google_client.php" in app/Helpers:
PHP Code:
function init_google_client(){
$client = new \Google_Client();
$client->setAuthConfig( ROOTPATH . 'xxxx.json' );
[...] etc.
$client->setRedirectUri( base_url() );
$client->setAccessType('offline'); // offline access
return $client;
}
Then in the before filter:
PHP Code:
helper('google_client');
$client = init_google_client();
I get an undefined error on the init function from this.
Alternatively, is there a better way to pass an object variable from a filter into subsequent controllers? The client object cannot be serialized into the SESSION array.
Thanks for help!
Evan