<?php
namespace App\Smarty\Functions; class ActivityDomainLabel { static public function create($params, $smarty) { $defaultOutput = ''; if ($params['default']) { $defaultOutput = $params['default']; } if (is_object($params['ref']) and get_class($params['ref'])=='Entity\ActivityDomain') { $domain = $params['ref']; } elseif (is_numeric($params['ref']) and $params['ref']>0) { $domain = \Entity\ActivityDomain::select($params['ref']); if (!$domain->recordExists()) { return $defaultOutput; } } else { return $defaultOutput; } if ($params['assign']) { $smarty->assign($params['assign'], $domain); return ''; } if (!$params['format']) { return $domain->name ? $domain->name : $defaultOutput; } else { $replaceArray = []; $replaceArray['%name%'] = $domain->name; return str_replace(array_keys($replaceArray), array_values($replaceArray), $params['format']); } } }