alphagov/specialist-publisher — pull request #95 by bestie (2014-05-21 13:11:11+00:00)
Title: Services for everything

This PR implements the service layer and service locator pattern for all controller actions.

## Service layer
Replaces the contents of each action will a call to an object that is responsible for offering that service e.g. CreateDocumentService.

## Service locator
Offers a layer of indirection between the controllers and the services allowing us to inject dependencies into the services which has the added benefit of configuration and re-use.

## Current duplication issues
There is some duplication across some of the service objects, especially where the current document or manual needs to be loaded. I did not want to DRY up this behaviour immediately without first settling on how we want to design services. I would consider wrapping services in another object which can fetch objects referenced in the URL, eliminating the need for multiple services to fetch the object with a particular id.

## Return values
Services return fetched or constructed objects back to controller. It would be advantageous to follow "Tell, don't ask" and use message passing to eliminate duplication logic which tests for success and redirects or displays errors.

An added benefit (see 1dfba6071dd405afabc78296f513a06e0acce344) is that the wiring does not expose all of its methods to all controllers. This should allow us a quick path to deprecating the unstructured wiring file and move to something more structured like a separate wiring file for each layer, for example we may want a `RepositoryRegistry` which can provide instances of all the different repositories.