Download & Extend

Module Object Oriented Programming API

R&D module.

If you can come up with any idea how this module could be useful please do let me know.

This module allows you to write modules in pure OOP syntax.
The only requirement is that oop syntax module must implement hook_boot() like so:

function hook_boot(){
  module_invoke('moopapi', 'register', '[YOUR CLASS NAME WHICH SHOULD BE THE MODULE NAME]');
}

This will register your class as module and will then simply work. Just enable it and enjoy.

Demo module to try this out: create ooptest.module and stick this code into it:

Enable both moopapi.module with ooptest.module and then visit either to /oop or /oop-test to see that it works :-D

ooptest.info:

; $Id$
name = OOPTest
description = The Next Level $417
core = 6.x
version = VERSION

ooptest.module:
<?php
//$Id$


class ooptest {

  public function
menu() {
   
$items = array();
   
$items['oop-test'] = array (
     
'title'            => 'OOP Page Test',
     
'page callback'    => 'ooptest_fark',
     
'access arguments' => array('access content'),
     
'type'             => MENU_NORMAL_ITEM,
    );
   
$items['oop'] = array (
     
'title'            => 'OOP FAPI Test',
     
'page callback'    => 'drupal_get_form',
     
'page arguments'   => array('ooptest_form'),
     
'access arguments' => array('access content'),
     
'type'             => MENU_NORMAL_ITEM,
    );
    return
$items;
  }
  public function
boot() {

  }
  public function
form_alter(&$form, $form_state, $form_id) {
    if (
'ooptest_form' == $form_id) {
     
$form['additional'] = array(
       
'#type' => 'radios',
       
'#title' => t('Is this cool or what!?!?!? - (hook_form_alter() item)'),
       
'#options' => array(
         
'Super cool!',
         
'Hell yeah!!!!',
        ),
       
'#default_value' => variable_get('additional', null),
       
'#weight' => -1,
      );
    }
  }
  public function
form() {
   
$form = array();
   
$form['testing'] = array(
     
'#type'  => 'textfield',
     
'#title'  => t('This is a test field (form item)'),
     
'#default_value' => variable_get('testing', '134'),

    );

    return
system_settings_form($form);
  }
  public function
fark () {
    return
'hello world 2.0 style';
  }
}

/**
* Implementing hook_boot() is a must, to force drupal to load this module as early as possible
* Druring hook_init phase moopapi_init() will initialize all the oop method wrappers and execute hook oop->boot()
*
*/
function ooptest_boot(){
 
module_invoke('moopapi', 'register', 'ooptest');
}
?>

Downloads

Recommended releases

Version Downloads Date Links
6.x-1.0 tar.gz (7.52 KB) | zip (8.2 KB) 2008-Oct-28 Notes

Development releases

Version Downloads Date Links
6.x-1.x-dev tar.gz (7.47 KB) | zip (8.07 KB) 2011-Feb-25 Notes

Project Information

  • Module categories: Developer, Utility
  • Maintenance status: Unknown
  • Development status: Unknown
  • Last modified: October 28, 2008

Maintainers for Module Object Oriented Programming API

  • litwol - 3 commits
    last: 3 years ago, first: 3 years ago

Issues for Module Object Oriented Programming API

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports
Oldest open issue: 29 Oct 08