Update TwigExtension.php

retrieve link from array or from object before every check