You are here

trait FrxAPI in Forena Reports 8

Implements FrxAPI Trait

This trait provides access to common Forena API's. Use this trait in your own classes to interact with the forena Toolbox.

Hierarchy

26 files declare their use of FrxAPI
BlockEditor.php in src/Editor/BlockEditor.php
DocumentBase.php in src/FrxPlugin/Document/DocumentBase.php
DocumentBase.inc Given a report, render the appropriate output given the document format. @author davidmetzler
DriverBase.php in src/FrxPlugin/Driver/DriverBase.php
Class that defines default methods for access control in an DriverBase
forena.common.inc in ./forena.common.inc
Common functions used throughout the project but loaded in this file to keep the module file lean.
forena.module in ./forena.module

... See full list

1 string reference to 'FrxAPI'
ReportEditor::blockLinks in src/Editor/ReportEditor.php

File

src/FrxAPI.php, line 18
FrxAPI.incL General Forena Reporting Class

Namespace

Drupal\forena
View source
trait FrxAPI {

  /**
   * Returns the data manager service
   * @return DataManager
   */
  public function dataManager() {
    return DataManager::instance();
  }

  /**
   * Returns the fornea document manager
   * @return \Drupal\forena\DocManager
   */
  public function documentManager() {
    return DocManager::instance();
  }

  /**
   * Return Data Service
   * @return \Drupal\forena\Context\DataContext
   */
  public function dataService() {
    return DataManager::instance()->dataSvc;
  }

  /**
   * Report an error
   *
   * @param string $short_message
   *   Short Error message
   * @param string $log
   *   Log message for system logs
   */
  public function error($short_message, $log = '') {
    AppService::instance()
      ->error($short_message, $log);
  }

  /**
   * Returns containing application service
   * @return \Drupal\forena\AppService
   */
  public function app() {
    return AppService::instance();
  }

  /**
   * Get the current report file system.
   * @return \Drupal\forena\File\ReportFileSystem
   */
  public function reportFileSystem() {
    return ReportFileSystem::instance();
  }

  /**
   * Load the contents of a file in the report file system.
   * @param $filename
   * @return string
   */
  public function getReportFileContents($filename) {
    return ReportFileSystem::instance()
      ->contents($filename);
  }

  /**
   * Get the current data context.
   * @return array|\SimpleXMLElement
   */
  public function currentDataContext() {
    return DataManager::instance()->dataSvc
      ->currentContext();
  }
  public function currentDataContextArray() {
    return DataManager::instance()->dataSvc
      ->currentContextArray();
  }

  /**
   * Get the context of a specific id.
   * @param $id
   * @return mixed
   */
  public function getDataContext($id) {
    return DataManager::instance()->dataSvc
      ->getContext($id);
  }

  /**
   * Set Data context by id.
   * @param string $id
   *   ID of the context to set
   * @param object | array $data
   *   Data contents to set.
   */
  public function setDataContext($id, $data) {
    DataManager::instance()->dataSvc
      ->setContext($id, $data);
  }

  /**
   * Push data onto the Stack
   * @param $data
   * @param string $id
   */
  public function pushData($data, $id = '') {
    DataManager::instance()->dataSvc
      ->push($data, $id);
  }

  /**
   * Pop data off of the stack.
   */
  public function popData() {
    DataManager::instance()->dataSvc
      ->pop();
  }

  /**
   * Change to a specific document type.
   * @param string $type
   *   The document type you are trying to retrieve.
   */
  public function setDocument($type = 'drupal') {
    DocManager::instance()
      ->setDocument($type);
  }

  /**
   * Get the current document
   * @return DocumentBase
   */
  public function getDocument() {
    return DocManager::instance()
      ->getDocument();
  }

  /**
   * Enter description here...
   *
   * @param \SimpleXMLElement $xml
   *   XML to grab
   * @param string $tag
   *   The tag name of the inner XML
   * @return string
   */
  function innerXML(\SimpleXMLElement $xml, $tag = '') {
    if (is_object($xml)) {
      if (!$tag) {
        $tag = $xml
          ->getName();
      }
      $xml_data = $xml
        ->asXML();
      $xml_data = preg_replace("/<\\/?" . $tag . "(.|\\s)*?>/", "", $xml_data);
    }
    return $xml_data;
  }

  /**
   * Run a report with a particular format.
   * @param $machine_name
   *   Name of report.
   * @parms array $parms
   *   Parameter values to pass to report
   * @return array|string
   */
  public function report($machine_name, $parms = []) {
    return ReportManager::instance()
      ->report($machine_name, $parms);
  }

  /**
   * Get list of skins.
   * @return array
   *   List of skins
   */
  public function skins() {
    return ReportManager::instance()
      ->skins();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FrxAPI::app public function Returns containing application service
FrxAPI::currentDataContext public function Get the current data context.
FrxAPI::currentDataContextArray public function
FrxAPI::dataManager public function Returns the data manager service
FrxAPI::dataService public function Return Data Service
FrxAPI::documentManager public function Returns the fornea document manager
FrxAPI::error public function Report an error
FrxAPI::getDataContext public function Get the context of a specific id.
FrxAPI::getDocument public function Get the current document
FrxAPI::getReportFileContents public function Load the contents of a file in the report file system.
FrxAPI::innerXML function Enter description here... 1
FrxAPI::popData public function Pop data off of the stack.
FrxAPI::pushData public function Push data onto the Stack
FrxAPI::report public function Run a report with a particular format. 1
FrxAPI::reportFileSystem public function Get the current report file system.
FrxAPI::setDataContext public function Set Data context by id.
FrxAPI::setDocument public function Change to a specific document type.
FrxAPI::skins public function Get list of skins.