first commit
This commit is contained in:
29
class/smarty_plugins/function.get_watchdog.php
Normal file
29
class/smarty_plugins/function.get_watchdog.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user