Skip to content

Action

Actions are classes that take care of one specific task. Controllers (HTML/JSON/XML/etc.), Console Commands, Nova Actions are just a thin layer that calls Action classes.

Conventions:

  • final and readonly
  • do not extend any base class
  • have only one public method: execute(...) (except optional magic ones)
  • execute method is transactional-safe
  • constructor-level Dependency Injection can be used
  • should not be aware about the context (request, session, HTTP/console/job)

You can read everything about actions in the Blogpost by Freek Van der Herten.