Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Drupal is a "multi-paradigm" framework, and only certain bits of it implement "a kind of" AOP: </p> <ul> <li>Drupal 7's render() function, for example, converts a set of nested arrays into output HTML by selecting appropriate templates based on basic precedence rules: in this way, Drupal is behaving a lot like an XSLT transform engine, where your theme's template files taken together constitute an input .xsl file and the input array nest is the initial .xml file. This means that there's something elegantly functional to the way that themeing works. </li> <li>Also, the D7 database abstraction layer is close to "straight" object orientation, although as Larry (see later) notes, there is a small amount of quasi-AOP in this OO layer. </li> </ul> <p>Drupal's AOP paradigm might be better visualized as event-driven, and it all happens through Drupal's concept of hooks. For example, when you do the following:</p> <ul> <li>write a module called mymodule</li> <li>in mymodule.module , create a function called <code>mymodule_init()</code></li> <li>enable this module in Drupal</li> </ul> <p>what you are declaring is, in pseudo-code:</p> <pre><code>subscribe mymodule to "hook events" of type init </code></pre> <p>When Drupal's core then runs <code>module_invoke_all('init')</code> (called in <code>_drupal_bootstrap_full()</code> - <a href="http://api.drupal.org/api/drupal/includes!common.inc/function/_drupal_bootstrap_full/7" rel="nofollow">code available here</a>) this is Drupal saying </p> <pre><code>notify all subscribers to "hook events" of type init that this has occurred by passing any relevant arguments to them and letting them run the code they define in their hook_init() </code></pre> <p>So while PHP is still a procedural language - and your <code>mymodule_init()</code> could do all sorts of crazy, unencapsulated things if you really wanted - Drupal is still in charge. Drupal in a sense decides whether or not to call your code in the first place.</p> <p>In this way, Drupal is able to turn its own execution phases into quasi-AOP, by defining <strong>joint points</strong> (the <code>module_invoke*()</code> functions) and letting you write your own <strong>pointcuts</strong> (your <code>mymodule_*()</code> function. whose naming convention must match Drupal's hook name.)</p> <p>For more background on this, and the multi-paradigmatic nature of Drupal especially, try <a href="http://www.garfieldtech.com/blog/language-tradeoffs" rel="nofollow">Larry Garfield's excellent blogpost</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload