This project is not covered by Drupal’s security advisory policy.

IMPORTANT: this is an experimental, educational, object-oriented tutorial module

This module currently offers no significant end-functionality to users, although the (incomplete but quite extensive) object-oriented bridge API for OOE could already be used by other modules.

Synopsis

The Object Oriented Examples (OOE) project is a unique educational tutorial module for Drupal7 intended primarily for enthusiasts of graphical software engineering with Unified Modeling Language (UML) and fans of object-oriented Design Patterns. It may also be of interest to advocates and practitioners of object-oriented software engineering who are not yet familiar with UML, especially those with some background in Java (or similar OO languages).

This is an actively maintained and evolving development project, with a dedicated live demonstration site and a gallery of graphical Unified Modeling Language (UML) diagrams of the OOE system.

OOE may also be taken to mean "One Of Each", as it endeavours to represent one of each of the capabilities of Drupal7 module development in purely object-oriented form, starting with object-oriented versions of some well known existing Drupal7 tutorials and examples.

It achieves this by using a special "bridge" between the Drupal7 contributed module API (via a specially organised .module file) and a completely object-oriented OOE world that uses a special PHP recipe that is (more) amenable to reverse engineering to graphical UML, currently optimised for processing with the PEAR:PHP_UML script into XMI and graphical modelling in the MagicDraw UML tool (although once in XMI any decent UML tool could be used).

When using the OOE classes one never has to deal directly with Drupal "by convention" structured arrays; instead, the Drupal arrays are encapsulated completely, and the OOE classes know how to build and hand off valid Drupal structured arrays to the Drupal contributed module API. By encapsulating Drupal structured arrays OOE also supports IDE prompting on operations/methods (and their tightly bound documentation) that is not possible with Drupal7's "by convention" structured arrays, as demonstrated in NetBeans IDE in this short video and this image:

Finally, when using OOE, one does not need to implement complex behaviours in the usual hooks, page handlers, and form handlers in the .module file; instead, OOE supports fully object-oriented page controllers and form controllers (although this currently requires a small and harmless tweak to the Drupal7 core's form.inc, see also below).

Requirements

The OOE module depends (as a "tip of the hat") on the experimental Page controller project.

It requires also the X Autoload class loader.

IMPORTANT: tweaks to Drupal7 core to support object-oriented form controllers

This experimental module currently requires a small and completely harmless tweak to the Drupal7 form.inc, as described at:

- Drupal 7.25: form.inc 1471: form_execute_handlers($type, &$form, &$form_state): $function($form, $form_state); Does not work for static class method 'Drupal\mymodule\FormContoller::handler'

- drupal_retrieve_form() issues Undefined index: warning on line 764 when static class method used as $form_id: hinders use of object-oriented FormController

The reason they are needed is that the Drupal7 forms system assumes procedural functions as form callbacks, whereas this module promotes object-oriented form callbacks on encapsulated methods.

2015-04-04: IMPORTANT UPDATE: Downloads now available: Drupal7 core patch required to support object-oriented form controllers; and OOE bundle with patched Drupal-7.-36

NEW: There is now a patch for Drupal 7.x-dev core as of 2015-04-04 (Drupal-7.36+) for the files includes/form.inc and includes/ajax.inc, making it easier for you experiment with this OOE tutorial module. There are also complete instructions available externally at: Download: a Drupal-7.x-dev patch to support the OO form controllers of the OOE tutorial module.

Please add your community support for inclusion of this modification into Drupal-7.++ !

NEW: Until the OOE form controller patch for Drupal7 core is accepted, you may now also experiment with the OOE tutorial module easily using this bundle: Download: OOE bundle with adapted Drupal-7.36 and installation instructions..

It's also very simple to edit the Drupal7 core includes/form.inc and includes/ajax.inc files after the code examples in the issue reports above, or using this guide.

Documentation

The OOE project is extensively documented as an educational tutorial, with a strong emphasis on aspects of the project related to graphical UML software engineering for PHP. The documentation includes:

- A detailed description of the OOE project and its aims on a dedicated project site, with live demonstrations.

- A unique gallery of graphical UML diagrams of the entire OOE project. These UML diagrams are also included in the project's Drupal.org Git repository along with the code !

- The generated API documentation.

- A set of UML-friendly PHP coding recipe and UML diagramming policy notes linked to UML diagram examples.

- Detailed inline comments in the code aimed at other Drupal developers, including quotes from Drupal.org docs and adapted Drupal.org code examples.

Related modules (and how they differ)

The Ghost project also demonstrates object-oriented page and form controllers for Drupal7, but it is not conceived as a graphical UML-friendly project, and does not endeavour to map the entire Drupal7 contributed module system (including blocks, menus, menu items, rendering, theming etc.) into an object-oriented API for contributed modules for Drupal7. Page and form controllers are just a small part of OOE.

Q: Is OOE an attempt at an object-oriented version of Drupal7 core (or a "better Drupal7") ?

No. OOE is designed specifically to work with the existing Drupal7 contributed module API by offering an object-oriented bridge to it. However, to the extent that it maps out the Drupal7 contributed module API in a UML-friendly object-oriented form it reveals a lot about Drupal7. OOE does not in any sense repeat the functionality of Drupal7 core.

Q: Is OOE already a complete object-oriented API mapping the entire Drupal7 system suitable for development of other object-oriented modules ?

No. So far it is deliberately only a functioning proof-of-concept with an emphasis on introducing a UML-amenable PHP coding style to the Drupal community, based on a few well known Drupal7 examples. But there is no reason it could not (given support and/or sponsorship) be extended to become a fully-fledged object-oriented module development system for Drupal7.

Q: But what about Drupal8 ? Isn't that object-oriented already ?

Drupal8 core introduces an increasing degree of object-orientation, but is not developed specifically with graphical UML software engineering in mind and is not particularly UML-friendly. A Drupal8 version of the UML-friendlier OOE demonstration module may in future be developed for Drupal8 also. (In any case, when the OOE module was commenced, Drupal8 was not yet mature enough to support a live demonstration site.)

Credits

The Object Oriented Examples (OOE) module is developed by Webel IT Australia, specialists in PHP-driven Drupal CMS web engineering, UML, SysML, Java and XML. In addition to using Drupal CMS for developing clients' web sites, Webel has used Drupal CMS for many years to develop educational web sites promoting graphical software engineering with Unified Modeling Language (UML) and graphical systems engineering with Systems Modeling Language (SysML).

Support the OOE project

If you are interesting in seeing OOE expanded to become a fully-fledged, UML-friendly, object-oriented API for Drupal7 module development, or in seeing a Drupal8 version developed, please consider supporting the project. Donations to the Object Oriented Examples (OOE) project may be made online via via PayPal.

Project Information

Downloads