30 lines
923 B
PHP
30 lines
923 B
PHP
<?php
|
|
|
|
use KupShop\KupShopBundle\Context\UserContext;
|
|
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
|
use KupShop\KupShopBundle\Util\Contexts;
|
|
|
|
function smarty_function_get_watchdog($params, &$smarty)
|
|
{
|
|
$result = null;
|
|
|
|
if (empty($params['product'])) {
|
|
throw new InvalidArgumentException('Missing required parameter \'product\'');
|
|
}
|
|
|
|
$id = (int) $params['product']['id'];
|
|
$variationId = !empty($params['id_variation']) ? (int) $params['id_variation'] : null;
|
|
|
|
$userContext = Contexts::get(UserContext::class);
|
|
if ($userContext->getActiveId()) {
|
|
$watchdog = ServiceContainer::getService(\KupShop\WatchdogBundle\Util\Watchdog::class);
|
|
$result = $watchdog->getWatchdog((int) $userContext->getActiveId(), $id, $variationId);
|
|
}
|
|
|
|
if (!empty($params['assign'])) {
|
|
$smarty->assign($params['assign'], $result);
|
|
} else {
|
|
return $result;
|
|
}
|
|
}
|