class DocManager in Forena Reports 8
Implements \Drupal\forena\DocManager @package Drupal\forena
Hierarchy
- class \Drupal\forena\DocManager
Expanded class hierarchy of DocManager
9 files declare their use of DocManager
- CSVTest.php in tests/
src/ Unit/ Document/ CSVTest.php - DocumentConfigForm.php in src/
Form/ DocumentConfigForm.php - DrupalTest.php in tests/
src/ Unit/ Document/ DrupalTest.php - EmailMerge.php in src/
FrxPlugin/ Document/ EmailMerge.php - EmailMergeForm.php in src/
Form/ EmailMergeForm.php
File
- src/
DocManager.php, line 15
Namespace
Drupal\forenaView source
class DocManager {
private static $instance;
private $writers = [];
private $type;
/** @var array */
protected $docTypes;
/**
* @return \Drupal\forena\DocManager
*/
public static function instance() {
if (static::$instance === null) {
static::$instance = new static();
}
return static::$instance;
}
/**
* Initilaize Document Manager
*/
public function __construct() {
// Determine plugins
/** @var \Drupal\forena\FrxDocumentPluginManager $pm */
$this->docTypes = AppService::instance()
->getDocumentPlugins();
$this
->setDocument('drupal');
}
/**
* @param string $type
* Document type
* @return \Drupal\forena\FrxPlugin\Document\DocumentInterface
* Generated class
*/
public function setDocument($type = '') {
if (!$type) {
$type = 'drupal';
}
if (!isset($this->writers[$type])) {
$class = $this->docTypes[$type];
$this->writers[$type] = new $class();
}
$this->type = $type;
return $this->writers[$this->type];
}
/**
* Gets current document.
* @return \Drupal\forena\FrxPlugin\Document\DocumentBase
*/
public function getDocument() {
return $this->writers[$this->type];
}
/**
* @return string
* Document type of current document.
*/
public function getDocumentType() {
return $this->type;
}
/**
* Return a list of document types.
* @return array
* List of doctype extensions possible.
*/
public function getDocTypes() {
return array_keys($this->docTypes);
}
/**
* @param string $base_name
* Name of file to set.
*/
public function setFilename($base_name) {
$ext = $this
->getDocumentType();
$this
->getDocument()
->setFilename("{$base_name}.{$ext}");
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DocManager:: |
protected | property | @var array | |
DocManager:: |
private static | property | ||
DocManager:: |
private | property | ||
DocManager:: |
private | property | ||
DocManager:: |
public | function | Return a list of document types. | |
DocManager:: |
public | function | Gets current document. | |
DocManager:: |
public | function | ||
DocManager:: |
public static | function | ||
DocManager:: |
public | function | ||
DocManager:: |
public | function | ||
DocManager:: |
public | function | Initilaize Document Manager |