Question about OpenDocument API development
| From: | Christian Weiske | Date: | Tue, 23 Jun 2009 05:45:44 +0000 |
| Subject: | Question about OpenDocument API development | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-52028@lists.php.net to get a copy of this message | ||
Hi all,
I'm making progress in understanding the OpenDocument package, reorganizing it and fixing bugs
in it. While tinkering with new content types (e.g. lists and images), I found that he current API
approach does not suffice. Let me explain:
- class OpenDocument_Text has two methods regarding adding content: createHeading and
createParagraph
- OpenDocument_Element_Paragraph has createSpan, createHyperlink, createText
- OpenDocument_Element_Heading has createSpan, createHyperlink, createText
- all of them should support createBookmark which they don't do yet. Potentially all of them
will be able to get images added to.
Currently, every single element class (+ the opendocument one) implements the create*() methods
itself, redirecting the calls to the element::instance() methods. What I don't like is that,
when adding support for a new element - e.g. lists - I have to do this in every single element class
that supports it!
So there needs to be a better way - for example using __call and throwing exceptions in the cases
the element-to-be-created is not supported. I could also try to find class hierarchies with elements
that are supported in certain classes only, and base them all off a common element class. The
problem with that approach is that I don't know yet if that hierarchy is tree-like or not. I
could also do take the quickform approach and use a general create('elementtype', $params)
function - as flexible as __call, but not very usable from a user's point of view in regard of
capturing the supported parameters.
What would you do?
--
Regards/Mit freundlichen Grüßen
Christian Weiske