You are here

public function Forena::runReport in Forena Reports 8

Parameters

string $report: Name of the report to run with format.

array $parms: Parameters to apply to report

Return value

string The report text.

File

src/Forena.php, line 43

Class

Forena

Namespace

Drupal\forena

Code

public function runReport($report, $parms = []) {
  $content = \Drupal\forena\ReportManager::instance()
    ->report($report, $parms);
  $d = \Drupal\forena\DocManager::instance();
  $doc_type = $d
    ->getDocumentType();
  $email_override = \Drupal::config('forena.settings')
    ->get('email_override');
  $user = \Drupal::currentUser();
  $email = $email_override ? $user
    ->getEmail() : '';
  switch ($doc_type) {
    case 'drupal':
      $content = $content['report']['#template'];
      break;
    case 'email':

      /** @var \Drupal\forena\FrxPlugin\Document\EmailMerge $merge */
      $merge = $d
        ->getDocument();
      $merge
        ->sendMail($email, 0);
      break;
  }
  return $content;
}