  In this paper we prove a general theorem showing the extension property for
partial automorphisms (EPPA, also called the Hrushovski property) for classes
of structures containing relations and unary functions, optionally equipped
with a permutation group of the language. The proof is elementary,
combinatorial and fully self-contained. Our result is a common strengthening of
the Herwig-Lascar theorem on EPPA for relational classes with forbidden
homomorphisms, the Hodkinson-Otto theorem on EPPA for relational free
amalgamation classes, its strengthening for unary functions by Evans,
Hubi\v{c}ka and Ne\v{s}et\v{r}il and their coherent variants by Siniora and
Solecki. We also prove an EPPA analogue of the main results of J. Hubi\v{c}ka
and J. Ne\v{s}et\v{r}il: All those Ramsey classes (Ramsey classes with closures
and forbidden homomorphisms), thereby establishing a common framework for
proving EPPA and the Ramsey property.
  Our results have numerous applications, we include a solution of a problem
related to a class constructed by the Hrushovski predimension construction.
