Files
kupshop/bundles/KupShop/ContentBundle/View/BlockHistoryView.php
2025-08-02 16:30:27 +02:00

48 lines
1014 B
PHP

<?php
namespace KupShop\ContentBundle\View;
use KupShop\KupShopBundle\Views\View;
use Query\Operator;
class BlockHistoryView extends View
{
use \DatabaseCommunication;
protected $template = 'block_edit.tpl';
private $blockId;
private $historyId;
public function setBlockId($blockId)
{
$this->blockId = $blockId;
}
public function setHistoryId($historyId)
{
$this->historyId = $historyId;
}
public function getBodyVariables()
{
$vars = parent::getBodyVariables();
$histories = sqlQueryBuilder()->select('data')->from('blocks_history')
->where(Operator::equals(['id' => $this->historyId]))
->execute()->fetchColumn();
$vars['block'] = current(
array_filter(
json_decode_strict($histories, true),
function ($value) {
return $value['id'] == $this->blockId;
}
)
);
return $vars;
}
}