Separation of Drupal module and user interface logic

I wrote a D6 module that provides the user with the ability to communicate, configure settings and test a third-party API service.
The module works as intended, but I want to separate the communicator class and bundle it as the foo module. Then pack the rest (admin page) as a foo-ui module. Just like looks and looks - ui.
I have no idea what best practices / design patterns are for this. Any idea?

+3
source share
3 answers

As I know, there is no specific template, but the question always arises:

- Why should I separate the logic of the module and the user interface from several modules? Is it really necessary?

This is only necessary if you have developed a module that can accept different user interfaces, such as views and simple views . IMO there is no other reason for this.

Well, believing that our module needs a thing _ui. Here I try to separate the main functions of the module and its configuration user interface as an example. Take a look at the Unfuddle API module , which is a pretty tiny and simple module that fits our case. Here $ tree ./unfuddle_api:

unfuddle_api/
|-- LICENSE.txt
|-- README.txt
|-- unfuddle_api.classes.inc
|-- unfuddle_api.info
|-- unfuddle_api.install
|-- unfuddle_api.module

0 directories, 6 files

! unfuddle_api.install , hook_uninstall(), , variable_del() . API, , .
IMO , unfuddle_api_ui.

unfuddle_api.classes.inc - API unfuddle, - , , .
. , variable_get() . .module.

unfuddle_api.module . hook_perm() hook_menu() unfuddle_api_create(), - a Factory Unfuddle, unfuddle_api.classes.inc.
_ui. ​​ variable_get() unfuddle_api.classes.inc, , unfuddle_api_create().

, : unfuddle_api, API Unfuddle. , . unfuddle_api_create() .
unfuddle_api_ui, unfuddle_api, , .

, .

+2
+2

. . API . API - simpletest. , "" API. , , , / , "" .

CTools. , ..

Drupal , , Java #. PHP . PHP. , "PHP " , , , .

- , . imagecache ( Imagecache, ). imagecache? [ - 1 + , , , , : -)]

+1

Source: https://habr.com/ru/post/1769100/


All Articles