Update TwigExtension.php

retrieve link from array or from object before every check
Merge pull request #436 from mila76/master

fix for current twig extension