3.0 Entity::toArray() should recurse into associated entities

As per #2341, when converting an entity instance into an array or JSON, any nested/related entities should also be transformed. This makes the rest of the framework not have to know the internals of entities, and fixes any issues where accessors were not being used for generating JSON.

### Questions I had while working on this

* Do we also want to allow virtual/calculated properties to be exported?
* How do we want to allow developers to 'hide' properties from JSON/array formats. For example you wouldn't want to include password hashes or encrypted blobs in your JSON. Perhaps a `$_hidden = ['password'];` property on the entity?