This is a paper that builds on a document published at API.Drupal.org that discusses the object oriented concepts and how they are applied in Drupal without using classes and object as expected.
Object Oriented Programming (OOP) in PHP
As most programming languages PHP supports Object Oriented Programming (OOP) through the use of classes which are the basis that forms objects that facilitate code reuse . The development of PHP was not planned with OOP, hence the fact that PHP was based on C which is a non-OOP language. Many PHP developers would continue for years without having to work with objects. Nevertheless, PHP is capable of providing modular code through objects and functions that allow large applications to run faster and benefit from implementations that support smooth upgrades .
The OOP characteristics of PHP are present in many of the Commercial of-the-shelf applications (COTs) that are made available in the market today; from Content Management Systems (CMS) and discussion forums, to Client Relationship Management (CRM) and Enterprise Resource Planning (ERP).
Drupal (www.drupal.org) is a content management system that was popularized with its wide range of modules and by the fact that it is distributed as an open source product under the General Public License (GPL). Drupal was based on PHP 4 which meant that many of the advanced features of OOP were not fully available for Drupal. New versions got improved with the enhancements that were deployed in PHP5 . In spite of that, Drupal is one of few applications out there that might seem completely procedural, yet implements most if not all of the concepts of OOP.
Drupal makes use of components addressed as “NODEs” that represent the various parts of the application such as pages, user objects, themes and plug-ins. Nodes use functions such as node_invoke() to call objects that provides operations on Nodes. The modular functions also determine what and who can perform actions on the node, which is predefined as the actions of viewing, deleting, updating or creation. A very intrinsic element in Drupal is it being built as a set of application programming interfaces APIs, which are defined in the form of modules. Modules in Drupal are components that can be thought of as plug-ins, and by themselves are object-like. Each module has a file associated with it, and incorporates its own set of variables and functions. Modules are also the main way to extend the use of Drupal and benefit from added functionality. Their interoperability is further extended by their compatibility with other modules and integration with different Drupal versions. Furthermore, modules can have additional behaviors comprised of other modules to be added extending the functionality of that particular module.
In terms of abstraction, Drupal uses a database abstraction layer, separating the integration with the database through a set of functions that allow developers to work with different databases without having to worry about SQL incompatibilities. These are taken care of by a set of functions such as db_query, db_query_range, pager_query, and tablesort_sql . Within the same concept, a Hook system is used within Drupal to build a framework that facilitates several operations for modules similar to the functionality provided to software applications by operating systems.