Forums / Suggestions / Some considerations on refactoring the eZ Publish API
Gaetano Giunta
Friday 23 April 2010 1:55:32 pm
List of current eZ Publish APIs: 1. template language API . template operators . template functions . template fetch functions . objects - template variables are not the same between node templates and module templates (persistent_variable, view_parameters) - no documentation of variables available in every template - some simple template operators miss (str_replace) - some template operators are named differently from their php counterpart - the variable scoping system is borderline blackmagic / it makes it difficult to pass variables up the include() chain + well documented 2. module views . positional params . named params . single/multiple actions . POST vars - extremely poorly documented - the view template is hardcoded into the view - redirects are hardcoded into the view (views are not atomic) 3. php code - misses a lot of "private" definitions on object members - should be documented in phpdoc style for current toolchains/ides - misses some architecture doc documenting the layering - still a few global variables and functions here and there (not 100% oop) IDEAS: + before/besides adding YOMA (yet one more api), improve existing ones + principle of discoverability: document better existing ones . add (optional) declaration of parameter types for views in module.php; it allows automatic type coercion (safety!), introspection (wsdl!) . add definition of all used POST/GET vars for views . add links to docs on ez.no site in the code; in the error messages; in the interface . an introspection view can be used in the backoffice to list all installed modules, views, fetch functions, including code from extensions . it should be doable to do the same with template functions/operators . add a 'description' member in definition of template operators, fetch functions (could be doable via an explicit member in the definition struct or via phpdoc parsing) + principle of least resistance: make APIs at the different levels identical or at least as similar as possible . the same operation executed by a view should be available via ws and via php . template operators and fetch functions should be available via php (ok for objects even though this is often overlooked, ok for fetch functions with some limitations, not for operators?) . make the module object available to the view templates
Principal Consultant International Business Member of the Community Project Board
Sunday 25 April 2010 11:22:28 pm
Some related issues:
http://issues.ez.no/IssueView.php?Id=16731&activeItem=1
http://issues.ez.no/IssueView.php?Id=16730&activeItem=2
http://issues.ez.no/IssueView.php?Id=16729&activeItem=3
http://issues.ez.no/IssueView.php?Id=16728&activeItem=4
http://issues.ez.no/IssueView.php?Id=16727&activeItem=5
http://issues.ez.no/IssueView.php?Id=16684&activeItem=8
http://issues.ez.no/IssueView.php?Id=16683&activeItem=10
Sunday 25 April 2010 11:23:58 pm
Some introspection capabilities have been added to extension ggsysinfo in release 0.2: http://projects.ez.no/ggsysinfo
Screenshots:
http://projects.ez.no/ggsysinfo/gallery/admin_interface_screenshots/list_of_available_fetch_functions
http://projects.ez.no/ggsysinfo/gallery/admin_interface_screenshots/list_of_available_views
Monday 03 May 2010 6:19:58 am
one more similar issue
http://issues.ez.no/IssueView.php?Id=16770
Thursday 27 May 2010 2:34:18 am
One more thing that would help introspection is better tagging of php classes methods (I think this is called "annotation" ).
In short: an example of a currently much needed information is "who does permission checking ?"
Afaik:
See issue http://issues.ez.no/IssueView.php?Id=16862 for the feat.request.
Tuesday 22 June 2010 1:44:56 am
Interesting blog post on the tpoic: http://blog.tabini.ca/2010/06/software-apis-and-all-the-kings-men/