[WIP] Extracting logic from twig pagerfanta extension