[dev] best coding practices with Horde_Views

Michael J Rubinsky mrubinsk at horde.org
Sun Sep 18 15:57:36 UTC 2016


Quoting Sebastian Birnbach <birnbacs at gmail.com>:

> In a PHP file that is subject to Horde_Form_Renderer->render() I whish to
> perform an Rdo query. This seems impossible as there is no $injector
> variable. This is the code I use successfully in the mother file and that
> fails in the daughter file:
>
>     $adapter = $injector->getInstance('Horde_Db_Adapter');
>     $factory = new Horde_Rdo_Factory($adapter);
>     $mapper = $factory->create('Abakus_Entity_DossierMapper');
>     $q = new Horde_Rdo_Query($mapper);
>     $q->sortby('ourref')
>       ->limit(8)
>       ->addTest('ourref', '=', Horde_Util::getFormData('search_id'));
>     $results = $mapper->find($q);
>
> The plan is to select one result, query for more fields of that result and
> format output those fields formatted. To make this reusable I seek to keep
> the query code in the PHP file that formats the output.
>
> So I tried to redirect from the first PHP file to another page so I could
> perform the query there. However, the redirection is giving me a headache,
> the obvious approaches do not work:
>
> (A)        Horde::url('heise.de')->redirect();
> (B)        $url = new Horde_Url('heise.de');
>              $url->redirect();
>
> The page output is blank every time.
>
> Any clues?

I don't really completely follow your description of the code  
structure - and I'm not sure where you are trying to access $injector  
- but as far as "there is no $injector variable" - if this code is  
within some non-global scope, you'll need to use $GLOBALS['injector']  
(or declare the $injector variable as global).


>   Sebastian
> --
> dev mailing list
> Frequently Asked Questions: http://wiki.horde.org/FAQ
> To unsubscribe, mail: dev-unsubscribe at lists.horde.org



-- 
mike
The Horde Project
http://www.horde.org
https://www.facebook.com/hordeproject
https://www.twitter.com/hordeproject
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2007 bytes
Desc: S/MIME Signature
URL: <https://lists.horde.org/archives/dev/attachments/20160918/53646dc7/attachment.bin>


More information about the dev mailing list