WordPoints / hooks-api

A basic API for hooking into user actions https://github.com/WordPoints/wordpoints/issues/321
GNU General Public License v2.0
0 stars 0 forks source link

Implement `WordPoints_EntityishI` in `WordPoints_Entity_Array` #38

Closed JDGrimes closed 8 years ago

JDGrimes commented 8 years ago

The WordPoints entity API consists mostly of classes which descend from WordPoints_Entityish and thus implement WordPoints_EntityishI. One exception is the WordPoints_Entity_Array class. This fact means that some methods accept WordPoints_EntityishI|WordPoints_Entity_Array, which is quite a mouthful. It would be cleaner if the entity array class was just an entityish, instead of being an odd man out.

In order to make that happen, the entity array class will need to implement three methods:

The main issue is get_title().

JDGrimes commented 8 years ago

These are our options with get_title():

The first two have the issue that we'd probably want to make this localizable, though since we don't use it we really wouldn't have to. But we'd need to figure out how to handle the fact that most users would probably have no idea what an "array" was.

The last option is really lame, even though we don't use this feature right now. But if we were going to just return nothing, we haven't really implemented the interface, have we? We could actually remove get_title() from the entityish interface, but that would probably make things worse instead of better. So I think we should pursue actually returning something meaningful from this.

So, if we need to decide how to describe this thing. What word can we use instead of "array"?

"Set" seems the best fitted in my judgement.

We musts also keep in mind that we have only the singular name of the entity, so we can't say "Set of %s", we'd have to say "%s set" instead, which seems strange. "%s collection" seems better.

JDGrimes commented 8 years ago

Let's just go with %s collection for now.

JDGrimes commented 8 years ago

This fact means that some methods accept WordPoints_EntityishI|WordPoints_Entity_Array, which is quite a mouthful.

Interestingly, most of these methods were documented as accepting WordPoints_EntityishI specifically, even though some of them could actually get passed entity arrays.