wi-events/classes/Jsonfile.php

40 lines
800 B
PHP
Raw Normal View History

2023-02-12 21:30:52 +01:00
<?php
namespace Zoomyboy\Event\Classes;
use Cms\Classes\CmsCompoundObject;
use File;
/**
* The CMS content file class.
*
* @author Alexey Bobkov, Samuel Georges
*/
class Jsonfile extends CmsCompoundObject
{
/**
* @var string the container name associated with the model, eg: pages
*/
protected $dirName = 'json';
/**
* @var array allowable file extensions
*/
protected $allowedExtensions = ['json'];
/**
* @var array list of attribute names which are not considered "settings"
*/
protected $purgeable = [];
public function markup(): array
{
return json_decode($this->content, true);
}
2023-08-20 10:26:51 +02:00
public function getVar(string $var, $default = null)
2023-02-12 21:30:52 +01:00
{
2023-08-20 10:26:51 +02:00
return array_get($this->markup(), $var, $default);
2023-02-12 21:30:52 +01:00
}
}