By DamienMcKenna: Fixed usage of $entity_type and $entity_info variables.