[dev] how to repair the conf object?
Ralf Lang
lang at b1-systems.de
Mon May 27 10:53:11 UTC 2019
Hi,
Am 27.05.19 um 12:15 schrieb Sebastian Birnbach:
> Am Sa., 25. Mai 2019 um 18:37 Uhr schrieb Michael J Rubinsky <
> mrubinsk at horde.org>:
>
>> [...]
>>
>> And this is the conf.xml of you own application, correct? I.e.
>> /horde/dossierstorage/conf/conf.xml?
>>
> My application is called abakus, the xml file is
> horde/abakus/config/conf.xml
> Other applications do not use their name in conf.xml so I don't either
>
>
>>
>>
>> It sounds to me like there is some error in how you are initializing
>> your application within horde and the application's context is leaking
>> out to other applications.
>
>
>> Did you create a registry entry for your
>> application?
>
> I did create file horde/config/registry.d/abakus.php with content
>
> <?php
>
> $this->applications['abakus'] = array('name' => _("Abakus")
>
> );
>
>
> Is there more to it?
>
>
>
>
>> Are you calling Horde_Registry::appInit() at the
>> beginning of each of your application's requests?
>>
> I do. Here is the api.php file I use for testing:
>
> <?php
>
> require_once __DIR__ . '/lib/Application.php';
> Horde_Registry::appInit('abakus');
> $page_output->header(array('title' => _("Nag API Test")));
>
> echo "<h3>Testing Nag API</h3>";
> echo "<pre>\n";
>
> echo "dossierstorage driver is " .
> $GLOBALS['conf']['dossierstorage']['driver'] . "\n";
>
> $nag = new Nag_Api();
> $tasks = $nag->listTasks();
> print_r($tasks);
>
> echo "</pre>\n";
> $page_output->footer();
>
> exit;
>
>
>> Normally, when you load an application, as part of the init process,
>> your application is pushed onto the registry stack and it's conf.php
>> values are merged with the horde(base) application's conf.php values.
>> There should be no other entries in $conf other than the horde/base
>> application and the currently scoped application.
>>
> I see. In api.php:
> * if I do an Horde_Registry::appInit('abakus'); the calling page (api.php)
> sees the abakus configuration but nag is unhappy
> * if I do an Horde_Registry::appInit('nag'); nag is happy but the calling
> page sees no abakus configuration
> * if I do both, whichever statement comes fist gets precedence.
>
> So, as you said, only one app is active at a time and an inactive app's
> configuration is not accessible.
>
> It surprises me that I need to appInit('nag') to use its API though.
> How do I work with my own application then?
You should let Horde take care of initializing other apps whose API you
are using.
Use $registry->call('app', 'method', $params) or the equivalent __call
shorthand to access the API.
Don't call into another app's classes directly.
--
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang at b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
More information about the dev
mailing list