Exposing module services in a Page Engine-based application - Printable Version
+- Aria Templates Forums (http://ariatemplates.com/forum)
+-- Forum: Public forums (/forumdisplay.php?fid=3)
+--- Forum: Specifications (/forumdisplay.php?fid=13)
+--- Thread: Exposing module services in a Page Engine-based application (/showthread.php?tid=182)
Exposing module services in a Page Engine-based application - flongo - 18 February 2014 16:16
Suppose you have two module controller instances, that we will call A and B, inside your page engine applications. They can be either common modules (declared in the site configuration) or page specific modules (declared in a page definition).
Sometimes A needs to call a method defined in B. This is currently impossible. Even in a standard application using Aria Templates (without the page engine), when two modules are added as sub-modules of the same parent, they cannot directly call methods on each other.
When module controllers are used in a page engine context, they can only share portions of their data model through the binding mechanism that is provided by the framework (http://www.ariatemplates.com/usermanual/latest/page_engine#bindings), which allows to share module data in the application data.
This possibility sometimes inspires developers to inject the instance of module controller in the application data, so that the methods provided by it become public. This is somehow a hack.
It would be convenient to also have a syntax to expose certain methods of a sub-module to all the others.
2. Use Cases
Suppose you have a common module that performs a login. It is declared in the site configuration
and it implements a method (declared in its public interface)
Another page-specific module declared in the "SEARCH" page
wants to be able to access the "loginMethod" function of the login module.
3. Technical solution
The suggested solution consists in a syntax to expose module controller methods as "services". Considering the same example as above, suppose you want to expose the "login" method of the login module. The syntax would be
Suppose now that the "serach module on the "SEARCH" page needs to access the "loginMethod" function of the login controller. this is the suggested syntax:
So the idea is to