[uml] flagplus.entitytype.inc

REFACTOR: this software engineering content is flagged as under consideration for refactoring.
HOT TIP: this content is flagged as highly recommended !

Webel module:

Package/Namespace: 

UML element type:

OOE stereotypes:

Relationships
Relationships (inverse)
In migrating from the Drupal7 Island function-and-hook "flatland" to a more OOP and UML-friendly world we endeavour to create "bridge" include files that mediate between the classic Drupal7 hooks of the .module and the OO Class libraries, which progressively encapsulate as class attributes, class constants, and interface/class methods, the data and operations that were in old-style functions.

A guiding principle is that a form-related include bridge file should use one and one only helper/builder class, with delegation from each of the form _build(), _ajax(), _validate() and _submit() functions of the bridge include file. The flagplus.entitytype.inc nearly achieves that in combination with EntityFilter, but it needs some help with a little trick as shown in the UML diagram below:

UML Diagram
Click on the UML diagram to view it in a lightbox image viewer. You may then zoom in (or just open the image in a new web browser tab using the Download Original link to view large diagrams).

UML modelling domain:

The themed builder theme_flagplus_page_bybundle_with_subforms() for the non-AJAX "by bundle" flag applicability form and the non-themed builder flagplus_form_bybundle_ajax() for the AJAX version of the flag applicability form delegate to theme() and build of BybundleFormBuilder and BybundleAjaxBuilder respectively, which in turn use the EntityFilter helper class, which defines callbacks.

But from the point of view of Drupal7 (which as of Drupal-7.36 still does not fully support object-oriented methods as callbacks), it has to callback on something known at the include file level where the form builder is originally invoked. So a module_load_include of flagplus.entitytype.inc (which handles delegating callbacks for EntityFilter) is performed in flagplus.flags.inc.

Not as nice as using a completely object-oriented form controller callback, but not too bad once you get the hang of it. Compare this approach with the fully object-oriented form controller approach IFormController of OOE = Object Oriented Examples = One Of Each, which unfortunately at the time of writing (2015-04-19) still requires some minor adaptations of Drupal7 core (OOE: special tweaks to Drupal7 core's form.inc required to support object-oriented form controllers) despite my attempts so far to get some harmless changes into Drupal7 core to support class methods as form callbacks. See also: Download: a Drupal-7.x-dev patch to support the OO form controllers of the OOE tutorial module .
Refactoring

The dependency on BybundleAbstractBuilder::THEME_VAR_ENTITY2FLAG looks suspicious, but that constant is used as a render array and form key in every subclass of BybundleAbstractBuilder, as well as in flagplus.module.

Notes (policies)
Visit also