Skip to main content
Start of main content.

Drupal Development

Drupal 8 Now: Object Oriented plugins in Drupal 7

Drupal 8's plugins system is the bees-knees, taking the lessons learnt from Drupal 7 and Ctools plugins.

But we want it now right?

So how can you write plugins for Drupal 7's ctools module that will be a breeze to update to Drupal 8?

Read on to find out more in this latest post in our Drupal 8 now series.

Object-oriented page callbacks for Drupal 7

In Drupal we use object-oriented page and form callbacks to ease our programmning burden This is a nice improvement that allows us to encapsulate the functionality of one or many page callbacks into objects, with all the benefits that brings. Is it possible for us to us object-oriented page callbacks in Drupal 7? With a few tricks, yes it is. This article shows you how.

This is part of a continuing series of using Drupal 8 programming techniques in Drupal 7.

Drupal consultant

Drupal 8 Now: PSR-0 code in Drupal 7

Drupal 8 embraces modern PHP with all the trimmings, shedding the baggage of supporting earlier PHP versions and embracing the new object-oriented features.

One such feature is namespaced objects and the PSR-0 standard for autoloader compatability.

But if you know your project will run on a recent version of PHP, there's no reason you can't write your custom modules using PSR-0 now, in Drupal 7

Drupal 8 Now: Writing Drupal 7 code with an eye towards Drupal 8

We're getting closer to that difficult stage. You know, that point where we're nearing a new major Drupal release. That point where customers with flexible delivery dates who are thinking about starting a new project are asking if they should wait for Drupal 8 to come out or build on Drupal 7.

Those of us who went through the Drupal 6 and Drupal 7 release know what I'm talking about. Do I build it on Drupal 6 or do I chance it on Drupal 7 and work through any missing modules.

We're not there yet for Drupal 8, but we already have customers asking us to develop Drupal 7 sites in a fashion sympathetic to Drupal 8.

So what does that mean? Well we have a few pointers on starting new Drupal 7 modules that will be easier to upgrade to Drupal 8 when the time comes. We'll present these in a new Drupal 8 Now! series of blog posts.

Advanced Testing of Drupal emails with Behat and TestingMailSystem

One of our recent projects had the following requirements:

Users receive points for creating/commenting on content
When they receive a certain points balance they are awarded some goodies in the mail
When they receive the achievement a notification email should be sent to the user and an admin

Setting this up with Userpoints, Userpoints Rules and Rules was fairly straightforward but as part of our Agile processes, the story isn't done until there is automated testing.

Read on to learn how we setup testing the email and their contents using Behat.

Come sprint with us on Drupal 8 Contrib at Drupal South

Friday February 14th is the DrupalSouth Code Sprint, and PreviousNext are descending en masse to Wellington, New Zealand, to participate.

As a team we've been discussing what we'd like to sprint on. We've collectively agreed that the sprint would be an opportune time to work on porting some of our favourite contrib modules to Drupal 8.

Read on to find out our plans and how you can get involved.

A potential default content solution for Drupal 8 core

Inspired by Jeff Eaton and Roy Scholten's session on install profiles from Drupalcon Prague, I recently set about building a potential Snowman install profile for a musician using Drupal 8.

During the process I came across a few bugs in core (patches filed of course) and then started working on the main missing piece of the puzzle - a default content solution - using the REST and Serialization API's already in core.

Dynamic Routes in Drupal 8 with a RouteSubscriber

Previously I have demonstrated how to create a new route controller in Using Drupal 8's new route controllers then how to restrict access to it in Controlling Access to Drupal 8 Routes with Access Checks. But that's not where the fun ends!

What about when we need to create a route dynamically. For example, if we need to create routes for content types that we don't know will exist in advance?  In Drupal 7, we created dynamic routes with a foreach loop in hook_menu(). In Drupal 8, we can do all this and more with a RouteSubscriber.

Introducing the EntityFormController

Drupal 8 comes with many new concepts. A lot of work has gone into expanding on Entities and forms. One such concept is the EntityFormController. The EntityFormController is a controller class for the management of forms for entities. Say for example your module Foo defines an entity Bar. Say you want to provide a form for this entity so that users can set some properties or field values. In the past you would have created a hook_menu item to a drupal_get_form callback. In Drupal 8 we do it a better way. We define a class which implements the EntityFormController. The base class provides some pre-built entity goodness, and we can extend the class to add whatever we need.

Senior Developer