[horde] access backend params inside a hook

Jan Schneider jan at horde.org
Fri Sep 19 09:24:56 UTC 2014


Zitat von A. Schulze <sca at andreasschulze.de>:

> Jan Schneider:
>
>> Zitat von A. Schulze <sca at andreasschulze.de>:
>>> $backends['ldap']['params']['host'] = ...
>>> $backends['ldap']['params']['basedn'] = ...
>>> how is it possible to use these values inside the userdn hook?
>
>
>> $injector->getInstance('Passwd_Factory_Driver')->backends contains  
>> all backend definitions.
>
> Hm. get an Exception...
>
> for testing purposes I have this horde/passwd/hooks.local.php
> <?php
> class Passwd_Hooks
> {
>     public function userdn($authid) {
>         Horde::logMessage('HOOK passwd.userdn: ldaphost: "' .  
> $injector->getInstance('Passwd_Factory_Driver')->backends['ldap']['params']['host'] . '"',  
> 'INFO');
>         return $authid;
>     }
> }
>
> and get this log:
> HORDE [passwd] Call to a member function getInstance() on a  
> non-object [pid 10812 on line 5 of  
> "/horde/passwd/config/hooks.local.php"]
>
> and this browserpage:
> Call to a member function getInstance() on a non-object
>
> 1. Horde_ErrorHandler::catchFatalError()
>
> Details
> Die vollständige Fehlermeldung wurde in Hordes Logdatei geschrieben  
> und für Administratoren weiter unten ausgegeben. Benutzer, die keine  
> Administratoren sind, bekommen diese Details nicht zu sehen.
>
> ErrorException Object
> (
>     [message:protected] => Call to a member function getInstance()  
> on a non-object
>     [string:Exception:private] =>
>     [code:protected] => 0
>     [file:protected] => /horde/passwd/config/hooks.local.php
>     [line:protected] => 5
>     [trace:Exception:private] => Array
>         (
>             [0] => Array
>                 (
>                     [function] => catchFatalError
>                     [class] => Horde_ErrorHandler
>                     [type] => ::
>                     [args] => Array
>                         (
>                         )
>
>                 )
>
>         )
>
>     [previous:Exception:private] =>
>     [severity:protected] => 1
>     [logged] => 1
> )

$injector is not in your scope.  
http://php.net/manual/en/language.variables.scope.php

-- 
Jan Schneider
The Horde Project
http://www.horde.org/
https://www.facebook.com/hordeproject



More information about the horde mailing list