tl;dr
I need to have TypeInterface::generateId(<object> $doc) where the <object> is different for each class that implements the interface
Hi guys
I'm wrecking my head with this.
I have an interface (TypeInterface) which needs to have a method like TypeInterface::generateId(Document $doc) that will return a generated id from the doc specs, so far so good.
the problem
The several documents have methods in common, like ::schema(), but all the properties are specific for each one. So from this I made the following interfaces
- DocumentInterface - holds the methods that all documents must have
- ObjectAInterface - holds the methods for the properties of Document type A
- ObjectBInterface - holds the methods for the properties of Document type B
So the class TypeA (which implements TypeInterface) generates the ID with some properties/methods of ObjectAInterface that ObjectBInterface doesn't have for the TypeB class
Questions:
- How can I achieve this?
- Best practices in these cases?
code
I've created a simple gist with the example code http://ift.tt/1FV1ljL
Aucun commentaire:
Enregistrer un commentaire