Preheat the oven to 180C/350F/Gas 4.
For the pastry, place all the ingredients – except the iced water - into a food processor. Pulse until you have mixture which resembles breadcrumbs. Add the water and pulse to combine. Wrap the dough in clingfilm and place in the fridge to chill until needed.
For the filling, blanch the potato slices in boiling salted water for a few minutes.
Meanwhile, gently fry the onion until soft and translucent. Then add the pancetta and fry until crisp.
In a clean pan, fry the gammon and sage for 1-2 minutes. Remove from the pan and leave to until the gammon is cool enough to handle, then roughly chop or tear it into small pieces.
In a shallow ovenproof dish, drizzle a little oil, add a layer of potatoes and top with some gammon. Next add a layer of the onion and pancetta mix and a layer of apples to the dish. Now add a layer of fried onion and another layer of gammon. Finally, add another layer of the onion and pancetta mix. Season with freshly ground black pepper and add a sprinkle of sugar.
Mix the cider, cornflour and double cream together. Season to taste with salt and freshly ground black pepper, then pour over the layers of filling.
Take chilled pastry from the fridge and, on a lightly floured work surface, roll out pastry to the thickness of a pound coin. Place the pastry on top of the filling in the ovenproof dish, crimp the edges and make a hole in the centre, so that moisture can escape.
Brush the pastry with the beaten egg and bake for an hour, or until the pastry is crisp and a rich golden-brown.