1

I would like to override my Forena data sources in a local settings file for development. I would also like them in settings.php on production for database independent deployment.

I have checked the documentation but a full example is not provided. Can anyone provide a full example?

2

A sample of what you are looking for can be found in Forena subfolder repos/sample/settings.php, it looks like so (and is for 7.x-4.x):

<?php
/*
 * Sample Repository configuration file
 */

/*
 * Security provider:  Specify the class name that is used to provide security
 */
$conf['access callback'] = 'user_access';

/*
 * Data provider:
 * Specify the class name that will be used to interpret data block files.
 * Note that data blocks in a repository
 *
 */
$conf['data provider'] = 'FrxPDO';

/*
 * URI:
 * The format of the uri depends on the type of data engine that's being used.
 * In database engines it might be the connection string to the db.  In the file
 * engine it would be the path to the directory containting the files
 */
$local_path = realpath(dirname(drupal_get_path('module','forena').'/forena.info'));
$conf['uri'] = 'sqlite:'. $local_path . '/repos/sample/sample.db';
$conf['debug'] = FALSE;
/**
 * Uncomment the following line to specify a particular path in which to save reports.
 * The default value would be controlled by Forena configuration page. If you'd like users
 * to be able to define their own reports in this repository then you need to make sure that this
 * is writable by the web user (e.g. apache).
 */
// $conf['report_path'] = 'sites/files/reports'

Disclosure: I'm a Forena co-maintainer.

| improve this answer | |
  • Thanks. I didn't accept your answer because I was looking for a way to handle multiple repositories. The version I provided below works to some extent but recently caused problems when migrating reports from one Drupal install to another. Maybe because I am missing both access_callback and user_callback? – lolcode Nov 8 '19 at 17:50
0

I have found a format that works in settings.php. It is actually shown in snippet form in the linked documentation but not fully expanded on.

global $_forena_repositories;
$_forena_repositories['source1'] =
  [
    'path' => 'sites/all/forena_repos/source1',
    'title' => 'Source1',
    'data provider' => 'FrxPDO',
    'uri' => 'mysql:host=mydb.site.localhost;dbname=source1;charset=UTF8',
    'user' => 'root',
    'password' => 'changeme',
  ];
$_forena_repositories['source2'] =
  [
    'path' => 'sites/all/forena_repos/source2',
    'title' => 'Source2',
    'data provider' => 'FrxPDO',
    'uri' => 'mysql:host=mydb.site.localhost;dbname=source2;charset=UTF8',
    'user' => 'root',
    'password' => 'changeme',
  ];
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.