XF 2.1 Custom Template Function Error

DDempsey

Member
Hello,

I've got a template with the following;
Code:
{{phx_steamauth_steamid32($providerData.provider_key)}}
Which is handled by a class extension for 'XF\Template\Templater'
PHP:
namespace Phoenix\SteamAuth\XF\Template;

use XF\Entity\User;

class Templater extends XFCP_Templater
{

    public function addFunctions(array $functions)
    {
        $functions['phx_steamauth_steamid32'] = '_getsteamid32';
        $functions['phx_steamauth_steamid64'] = '_getsteamid64';

        return parent::addFunctions($functions);
    }

    function _getsteamid32($id)
    {
        if (is_numeric($id) && strlen($id) >= 16)
        {
            $z = bcdiv(bcsub($id, '76561197960265728'), '2');
        }
        elseif (is_numeric($id))
        {
            $z = bcdiv($id, '2'); // Actually new User ID format
        }
        else
        {
            return $id; // We have no idea what this is, so just return it.
        }
        $y = bcmod($id, '2');
        $id = 'STEAM_0:' . $y . ':' . floor($z);
        return array($id);
    }

    function _getsteamid64($id)
    {
        if (preg_match('/^STEAM_/', $id))
        {
            $parts = explode(':', $id);
            return bcadd(bcadd(bcmul($parts[2], '2'), '76561197960265728'), $parts[1]);
        }
        elseif (is_numeric($id) && strlen($id) < 16)
        {
            return bcadd($id, '76561197960265728');
        }
        else
        {
            return $id; // We have no idea what this is, so just return it.
        }
    }
}
It should just return a string of the converted steamID however I get the following error

  • Template public:connected_account_associated_steam: Object of class Phoenix\SteamAuth\XF\Template\Templater could not be converted to string (src/XF.php:930)

When I {{ dump(phx_steamauth_steamid32($providerData.provider_key) }} I get this weird array
Code:
Templater {#305 ▼
  #uix_uploadable_style_properties: array:7 [▶]
  #uix_materialColors: array:96 [▶]
  #app: App {#2 ▶}
  #router: Router {#309 ▶}
  #routerType: null
  #pather: Closure {#307 ▶}
  #jsBaseUrl: "js"
  #language: Language {#218 ▶}
 
Top