Maslosoft Staple API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
<?php
/**
* This software package is licensed under AGPL or Commercial license.
*
* @package maslosoft/staple
* @licence AGPL or Commercial
* @copyright Copyright (c) Piotr Masełkowski <pmaselkowski@gmail.com>
* @copyright Copyright (c) Maslosoft
* @link http://maslosoft.com/staple/
*/
namespace Maslosoft\Staple\Processors\Pre;
use Maslosoft\Staple\Interfaces\PreProcessorInterface;
use Maslosoft\Staple\Interfaces\RendererAwareInterface;
/**
* ##Data Json Extractor##
*
* This extracts json data from content folder.
* By default it's name is `data.json`
* @author Piotr Maselkowski <pmaselkowski at gmail.com>
*/
class DataJsonExtractor implements PreProcessorInterface
{
public $filename = 'data.json';
public function decorate(RendererAwareInterface $owner, &$content, $data)
{
}
public function getData(RendererAwareInterface $owner, $filename, $view)
{
$data = [];
$path = sprintf('%s/%s/%s', $owner->getRootPath(), $owner->getContentPath(), $this->filename);
if (file_exists($path))
{
$data = (array) json_decode(file_get_contents($path));
}
return $data;
}
}
API documentation generated by ApiGen