Drupal finally using OOP

Entities will be real PHP Classes in Drupal 8

Finally. This is a huge step forward for Drupal. After eschewing OOP practices for a long time, its finally winning over core developers, which will make working with Drupal as a Framework easier in many ways. I copied the announcement below, but you can see that patch and discussion here.

This patch is about to be committed. It is the foundation to change for example $comment from an stdClass to a comment specific class allowing for $comment->save(). This is a monumental change and everyone is invited to review and familiarize with the new system even before it is committed.

What is possible when you use proper classes? The first thing I envision is a plugin/pluggable system in the same way that Zend Framework allows you to use Controller Plugins and View Helpers from a pluggable object, without the need to inherit or compose an object. For example, in a Zend View, you can call a partial like this:

</p>
<!--?php
// $this is a view instance
echo $this--->
<p>partial('my-partial.html');
?>

Now, the View class doesn't have a method named partial, instead the magic __call method intercepts the call, gets the Partial view helper, and calls its invoke method.

Related Items

When a prominent developer and contributor lashes out that Drupal is in dire...
While Panels is great for controlling the layout of drupal pages, there are...
This is a concise example showing how you can use the Features module to bundle...
On development, testing, and staging site you normally don't want Drupal's...
Cal Evans wrote a straightforward and excellent tutorial on how to to use...
I ran into SSL timeouts on in local development setup when I was re-factoring...

Comments

Subscribe by Email

Enter your email address:

Delivered by FeedBurner