In this example I define two custom function.
1 - countryFilter function get's the country short code as input and return the country full name.
2 - _countPrinterTasks is used to calculate the no of tasks assigned to a particular user.
<?php
namespace DashboardBundle\Twig\Extension;
use ...