<?php
namespace App\Smarty\Functions; class BankAccountLabel { static public function create($params, $smarty) { $defaultOutput = ''; if ($params['default']) { $defaultOutput = $params['default']; } if (is_object($params['ref']) and get_class($params['ref'])=='Entity\AgencyBankAcount') { $bankAccount = $params['ref']; } elseif ( is_numeric($params['ref']) and $params['ref']>0 ) { $bankAccount = \Entity\AgencyBankAccount::select($params['ref']); if (!$bankAccount->recordExists()) { return $defaultOutput; } } else { return $defaultOutput; } if ($params['assign']) { $smarty->assign($params['assign'], $bankAccount); return ''; } if (!$params['format']) { $display = $bankAccount->account; if (!$display) { $display = $defaultOutput; } if ($params['hideLink']) { return $display; } else { return $display; } } else { $replaceArray = []; $replaceArray['%account%'] = $bankAccount->account; if (strpos($params['format'], '%bankName%')!==false) { $replaceArray['%bankName%'] = $bankAccount->bank->name; } return str_replace(array_keys($replaceArray), array_values($replaceArray), $params['format']); } } }