<?php
namespace Engine\Logger\Context; class Json extends \Engine\Logger\Context\StringRaw { public function __construct($value) { $this->value = json_encode($value, JSON_HEX_QUOT | JSON_PRETTY_PRINT | JSON_FORCE_OBJECT); } protected function renderOperations_groups($classes) { $outputOperations = parent::renderOperations_groups($classes); $outputOperations.= "<span class='group'>"; $outputOperations.= "<button data-group='reformat' data-type='raw' class='active'>raw</button>"; $outputOperations.= "<button data-group='reformat' data-type='json'>as json</button>"; $outputOperations.= "</span>"; return $outputOperations; } protected function renderOperations_download_determineData(array $classes, $logRow=null, $key=null) { $fileName = "file"; $fileExtension = "json"; if ($logRow && $key) { $fileName = sprintf("%s-%s", $logRow['logSession'], $key); } $value = $this->value; return [$fileName, $fileExtension, $value]; } } 