AjaxCommandBase.php in Forena Reports 7.4
File
AjaxCommand/AjaxCommandBase.php
View source
<?php
namespace Drupal\forena\FrxPlugin\AjaxCommand;
use Drupal\forena\Token\ReportReplacer;
abstract class AjaxCommandBase implements AjaxCommandInterface {
protected $replacer;
public function __construct($replacer) {
$this->replacer = $replacer;
}
public function getSetting(&$settings, $key) {
$value = NULL;
if (isset($settings[$key])) {
$value = $settings[$key];
unset($settings[$key]);
}
$this->replacer
->replaceNested($value);
return $value;
}
public function getJSONText(&$settings, $default_key = '') {
$data = [];
if ($default_key && isset($settings[$default_key])) {
$data = $settings[$default_key];
unset($settings[$default_key]);
}
if (!empty($settings['text'])) {
$data = $settings['text'];
unset($settings['text']);
}
if (!is_array($data) || !is_object($data)) {
$data = @json_decode($data);
if (!$data) {
$data = [];
}
}
$this->replacer
->replaceNested($data);
return $data;
}
}