Planet Drupal

Subscribe to Planet Drupal feed - aggregated feeds in category Planet Drupal
Updated: 1 hour 49 min ago

Love Huria: Keeping It Clean: Coding Standards That Matter

25 July 2017 - 11:00pm

A year back, I was working on a project that taught me how to keep my code clean, modular, reusable, and all those terms that seem fancy, but are actually good for you in the long run. Interesting? Yeah a bit.

But what did I do after getting into those practices?

I made mistakes. Believe me, a lot of them. But with every mistake, I learnt a lot of stuff that I had never considered before. It helped me in my thinking process, on how we should build things, what steps we need to consider when we are developing/extending a...

Categories: Drupal

Hook 42: Fun in the Sun at Drupal Camp LA 2017

25 July 2017 - 2:36pm

We are keeping busy this summer! Immediately following Drupal Govcon we are sending Aimee and AmyJune to Drupal Camp Los Angeles. Fun in the sun while doing the Drups'.

Come find us at our sessions, panels, or in the hall to pick up some cool stickers and pleasant conversation.

Categories: Drupal

Acquia Lightning Blog: Acquia Doctrine dependencies

25 July 2017 - 12:07pm
Acquia Doctrine dependencies Adam Balsam Tue, 07/25/2017 - 15:07

We started receiving reports of broken Lightning builds due to the release of doctrine/common:2.8.0 and/or doctrine/inflector:1.2.0 which require php ~7.1 and php ^7.0 respectively.

Lightning actually doesn't have a direct dependency on anything under the doctrine namespace. The dependencies come from drupal/core. So should drupal/core constrain doctrine/common to <=2.7.3 so that it continues to support php 5.6? No.

If you follow the dependency tree for what happens when you run composer update for a Lightning project in a php 5.6 environment, it looks like this:

  • acquia/lightning:2.1.7 requires:
  • drupal/core:~8.3.1, drupal/core:8.3.5 requires:
  • doctrine/common:^2.5, doctrine/common:2.8.0 requires php ~7.1, so it will resolve to 2.7.3, which requires:
  • doctrine/inflector:1.*, doctrine/inflector:1.2.0 requires php:^7.0, so it will resolve to 1.1.0, which simply requires php:>=5.3.2

So why are we getting reports of broken builds?

The problem arises when:

  1. Your project commits its composer.lock file (which it generally should)
  2. Your development environment has a different php version than your CI or production/test environment

If you have php 7.0 installed locally, the dependency resolution for doctrine/inflector will look like this:

  • acquia/lightning:2.1.7 requires:
  • drupal/core:~8.3.1, drupal/core:8.3.5 requires:
  • doctrine/common:^2.5, doctrine/common:2.8.0 requires php ~7.1, so it will resolve to 2.7.3, which requires:
  • doctrine/inflector:1.*, which will resolve to doctrine/inflector:1.2.0

Which will lock doctrine/inflector to v1.2.0; which requires php ^7.0. Then when you push to your php 5.6 CI environment, you'll get an error like this:

Problem 1
    - Installation request for doctrine/inflector v1.2.0 -> satisfiable by doctrine/inflector[v1.2.0].
    - doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.24) does not satisfy that requirement.
Problem 2
    - doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.24) does not satisfy that requirement.
    - doctrine/common v2.7.3 requires doctrine/inflector 1.* -> satisfiable by doctrine/inflector[v1.2.0].
    - Installation request for doctrine/common v2.7.3 -> satisfiable by doctrine/common[v2.7.3].

The solution, of course, is to run composer update in a dev environment that matches your CI/test/production environment.

Categories: Drupal

Xeno Media: WordPress coding standards for the Drupal developer

25 July 2017 - 8:17am

If you've been doing Drupal development for any amount of time, chances are that you have installed the Drupal Code to help you write clean, compliant code. Coder allows you to check your Drupal code against the Drupal coding standards and other best practices using PHP_CodeSniffer.  It can be configured to work in your IDE, and also works on the command line.

Writing code according to standards helps avoid common errors, and helps teams understand the code faster.

I installed Coder using Composer per the well written instructions.  Using this method installs it globally, so I can use it on all of my projects, and installs all the dependencies, including PHP_CodeSniffer.

I recently was tasked with working on a Wordpress site, and I started looking into the WordPress Coding Standards.  My setup didn't jive with the standard installation method since I already had PHP_CodeSniffer installed globally using composer.  I had to do a little digging to add these additional standards to my already installed setup.

Here is a quick recap on how to install Coder using composer.

Install Coder composer global require drupal/coder

To make the commands available globally, add this line to your .~/bash_profile, and that it is sourced (or restarted your terminal).

# Composer recommended PATH export PATH="$PATH:$HOME/.composer/vendor/bin"

Tell phpcs where the Drupal and DrupalPractice standards are located:

phpcs --config-set installed_paths ~/.composer/vendor/drupal/coder/coder_sniffer

Verify it worked with:

phpcs -i

You should see:

The installed coding standards are MySource, PEAR, PHPCS, PSR1, PSR2, Squiz, Zend, Drupal, and DrupalPractice

You can now navigate to your Drupal project and run the following command to use:

phpcs --standard=Drupal file.nameInstall Wordpress Coding Standards

Thanks to some help I found in the issue queue, here are the steps to install the Wordpress Coding Standards globally using composer.

composer global require wp-coding-standards/wpcs:dev-master

Again, to make these commands available globally, make sure you have this line in your ~/.bash_profile, and that it is sourced (or restarted your terminal).

# Composer recommended PATH export PATH="$PATH:$HOME/.composer/vendor/bin"

Like we did with Drupal, we need to tell phpcs where the Wordpress standards are located. We use the same installed_paths configuration set, and use a comma to list both the Drupal and Wordpress paths.

phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer,$HOME/.composer/vendor/wp-coding-standards/wpcs

Verify it worked with:

phpcs -i

You should now see:

The installed coding standards are MySource, PEAR, PHPCS, PSR1, PSR2, Squiz, Zend, Drupal, DrupalPractice, WordPress, WordPress-Core, WordPress-Docs, WordPress-Extra and WordPress-VIP

You can now navigate to your Wordpress project and run the following command to use:

phpcs --standard=Wordpress file.nameAdd aliases

If you've worked with me, or read my posts before, you know I love aliases. They streamline your process and help make you more productive. Add these aliases into your .bash_profile, .bashrc, or wherever you keep your aliases, and source it, or restart your terminal.

alias drupalcs="phpcs --standard=Drupal --extensions='php,module,inc,install,test,profile,theme,css,info,txt,md'" alias wpcs="phpcs --standard=Wordpress"

After this you can simply type drupalcs folder_name or wpcs and start writing better code!


Thanks to Micheal Porter, Albert Jankowski, and Mike Acklin for the technical review of this article, and to all the maintainers!

Photo by Ilya Pavlov on Unsplash

Categories: Drupal

DrupalCon News: Reserve your room for DrupalCon Vienna

25 July 2017 - 7:05am

For DrupalCon Vienna, our partner hotel, Courtyard Vienna Prater, is located in the Trabrennstraße area, where you can explore St. Stephen's Cathedral and Vienna's famous Prater park. And, the hotels we chose are perfect hubs for connecting you to a rewarding DrupalCon experience.

The fun is where the Drupalers are. Stay with us at a partner hotel to network and socialize after sessions end.

Categories: Drupal

InternetDevels: How Drupal 8 saves time & money, or a few words about backwards compatibility

25 July 2017 - 5:50am

Migration to Drupal 8 will save your time, effort and money in the future. It’s a fact! Discover
the great news about easy upgrades and backwards compatibility.

Read more
Categories: Drupal

ARREA-Systems: Usage of ClamAV in Drupal 8

25 July 2017 - 2:17am
Usage of ClamAV in Drupal 8 Tue, 07/25/2017 - 17:17

This is an example of anti-virus implementation with an Ubuntu server.

Our back office management solution allows users to upload files in various sections of the application for storage or file sharing. For this reason, checking of files for virus is an important advantage.

We use the ClamAV module integration from Drupal 8.


1) Install ClamAV on Ubuntu

Installation on Ubuntu server is straight forward.  However, it is better to install with clamav-daemon clamav-freshclam options for later settings

Categories: Drupal Blog: AGILEDROP: Top Drupal 8 Modules

24 July 2017 - 10:55pm
Last time, we have looked at the most popular Drupal modules. There are around 12 000 modules available for Drupal 7 and 3 000 for Drupal 8, of whom only 1 000 are in a stable version. Not so much as some would perhaps expect. However a lot of them make our lives easier each day, so this time we will look at the top Drupal 8 modules. Firstly, we must point out that modules that were already used in the blog post Most popular Drupal modules will be left out. Namely, we already presented, which are available for Drupal 8 and their popularity makes them useful for the newest version of Drupal… READ MORE
Categories: Drupal

Freelock : How do you keep a high bar of quality on dozens of sites every day?

24 July 2017 - 4:33pm

DevOps is the union of development, operations, and quality assurance -- but it's really the other way around. You start with the quality -- developing tests to ensure that things that have broken in the past don't break in the future, making sure the production environment is in a known, fully reproducible state, and setting protections in place so you can roll back to this state if anything goes wrong.

DevOpsBehavior Driven DevelopmentDrupalWordPressContinuous DeploymentContinuous IntegrationDrupal Planet
Categories: Drupal

Lullabot: Merging Entities During a Migration to Drupal 8

24 July 2017 - 12:25pm

Migrations provide an excellent opportunity to take stock of your current content model. You’re already neck deep in the underlying structures when planning for data migrations, so while you’re in there, you might as well ensure the new destination content types will serve you going forward and not present the same problems. Smooth the edges. Fill in some gaps. Get as much benefit out of the migration as you can, because you don’t want to find yourself doing another one a year from now.

This article will walk through an example of migrating part of a Drupal 7 site to Drupal 8, with an eye toward cleaning up the content model a bit. You will learn:

  • To write a custom migrate source plugin for Drupal 8 that inherits from another source plugin.
  • To take advantage of OO inheritance to pull field values from other entities with minimal code.
  • To use the Drupal 8 migrate Row object to make more values available in your migration yaml configuration.
Scenario: A music site moving from Drupal 7 to Drupal 8

Let’s say we have a large music-oriented website. It grew organically in fits and starts, so the data model resembles a haphazard field full of weeds instead of a well-trimmed garden. We want to move this Drupal 7 site to Drupal 8, and clean things up in the process, focusing first on how we store artist information.

Currently, artist information is spread out:

  • Artist taxonomy term. Contains the name of the artist and some other relevant data, like references to albums that make up their discography. It started as a taxonomy term because editors wanted to tag artists they mentioned in an article. Relevant fields:

    • field_discography: references an album content type.
  • Artist bio node. More detailed information about the artist, with an attached photo gallery. This content type was implemented as the site grew, so there was something more tangible for visitors to see when they clicked on an artist name. Relevant fields:
    • field_artist: term reference that references a single artist taxonomy term.
    • field_artist_bio_body: a formatted text field.
    • field_artist_bio_photos: a multi-value file field that references image files.
    • field_is_deceased: a boolean field to mark whether the artist is deceased or not.
Choosing the Migration’s Primary Source

With the new D8 site, we want to merge these two into a single node type. Since we are moving from one version of Drupal to another, we get to draw on some great work already completed.

First, we need to decide which entity type will be our primary source. After some analysis, we determine that we can’t use the artist_bio node because not every Artist taxonomy term is referenced by an artist_bio node. A migration based on the artist_bio node type would leave out many artists, and we can’t live with those gaps.

So the taxonomy term becomes our primary source. We won’t have an individual migration at all for the artist_bio nodes, as that data will be merged in as part of the taxonomy migration.

In addition to the migration modules included in core (migrate and migrate_drupal), we’ll also be using the migrate_plus module and migrate_tools.

Let’s create our initial migration configuration in a custom module, config/install/migrate_plus.migration.artists.yml.

id: artists label: Artists source: plugin: d7_taxonomy_term bundle: artist destination: plugin: entity:node bundle: artist process: title: name type: plugin: default_value default_value: artist field_discography: plugin: iterator source: field_discography process: target_id: plugin: migration migration: albums source: nid

This takes care of the initial taxonomy migration. As a source, we are using the default d7_taxonomy_term plugin that comes with Drupal. Likewise, for the destination, we are using the default fieldable entity plugin.

The fields we have under “process” are the fields found on the Artist term, though we are just going to hard code the node type. The field_discography assumes we have another migration that is migrating the Album content type.

This will pull in all Artist taxonomy terms and create a node for each one. Nifty. But our needs are a bit more complicated than that. We also need to look up all the artist_bio nodes that reference Artist terms and get that data. That means we need to write our own Source plugin.

Extending the Default Taxonomy Source Plugin

Let’s create a custom source plugin, that extends the d7_taxonomy_term plugin.

use Drupal\taxonomy\Plugin\migrate\source\d7\Term; use Drupal\migrate\Row; /** * * @MigrateSource( * id = "artist" * ) */ class Artist extends Term { /** * {@inheritdoc} */ public function prepareRow(Row $row) { if (parent::prepareRow($row)) { $term_id = $row->getSourceProperty('tid'); $query = $this->select('field_data_field_artist', 'fa'); $query->join('node', 'n', 'n.nid = fa.entity_id'); $query->condition('n.type', 'artist_bio') ->condition('n.status', 1) ->condition(fa.field_artist_tid, $term_id); $artist_bio = $query->fields('n', ['nid']) ->execute() ->fetchAll(); if (isset($artist_bio[0])) { foreach (array_keys($this->getFields('node', 'artist_bio')) as $field) { $row->setSourceProperty($field, $this->getFieldValues('node', $field, $artist_bio[0]['nid'])); } } } } }

Let’s break it down. First, we see if there is an artist_bio that references the artist term we are currently migrating.

$query = $this->select('field_data_field_artist', 'fa'); $query->join('node', 'n', 'n.nid = fa.entity_id'); $query->condition('n.type', 'artist_bio') ->condition('n.status', 1) ->condition(fa.field_artist_tid', $term_id);

All major D7 entity sources extend the FieldableEntity class, which gives us access to some great helper functions so we don’t have to write our own queries. We utilize them here to pull the extra data for each row.

if (isset($artist_bio[0])) { foreach (array_keys($this->getFields('node', 'artist_bio')) as $field) { $row->setSourceProperty($field, $this->getFieldValues('node', $field, $artist_bio[0]['nid'])); } }

First, if we found an artist_bio that needs to be merged, we are going to loop over all the field names of that artist_bio. We can get a list of all fields with the FieldableEntity::getFields method.

We then use the FieldableEntity::getFieldValues method to grab the values of a particular field from the artist_bio.

These field names and values are passed into the row object we are given. To do this, we use Row::setSourceProperty. We can use this method to add any arbitrary value (or set of values) to the row that we want. This has many potential uses, but for our purposes, the artist_bio field values are all we need.

Using the New Field Values in the Configuration File

We can now use the field names from the artist_bio node to finish up our migration configuration file. We add the following to our config/install/migrate_plus.migration.artists.yml:

field_photos: plugin: iterator source: field_artist_bio_photos process: target_id: plugin: migration migration: files source: fid 'body/value': field_artist_bio_body 'body/format': plugin: default_value default_value: plain_text field_is_deceased: field_is_deceased

The full config file:

id: artists label: Artists source: plugin: d7_taxonomy_term bundle: artist destination: plugin: entity:node bundle: artist process: title: name type: plugin: default_value default_value: artist field_discography: plugin: iterator source: field_discography process: target_id: plugin: migration migration: albums source: nid field_photos: plugin: iterator source: field_artist_bio_photos process: target_id: plugin: migration migration: files source: fid 'body/value': 'field_artist_bio_body/value' 'body/format': plugin: default_value default_value: plain_text field_is_deceased: field_is_deceased Final Tip

When developing custom migrations with the Migrate Plus module, configuration is stored in the config/install of a module. This means it will only get reloaded if the module is uninstalled and then installed again. The config_devel module can help with this. It gives you a drush command to reload a module’s install configuration.

Categories: Drupal

Mediacurrent: Creating Content with YAML Content Module

24 July 2017 - 5:37am

In my previous post, I introduced the YAML Content module and described the goal and usage for it at a high level. In this post, I aim to provide a more in-depth look at how to write content for the module and how to take advantage of a couple of the more advanced options included.

Categories: Drupal

Vardot: Top 10 Free Drupal Themes

24 July 2017 - 1:57am
Top 10 Free Drupal Themes Dmitrii Susloparov Mon, 07/24/2017 - 11:57

As of July 2017, there are 1500+ themes registered with the Drupal project. The sheer number of choices makes the selection of a theme difficult for most newcomers to Drupal. Some Drupal themes are free while the rest are known as being premium, i.e., they are available for a fee. Sometimes you can save more money by investing in a paid theme, but this topic we’ll cover in another article. This one lists the top 10 free Drupal themes, each of them in our opinion is a great choice for a beginning sitebuilder.

Are you a Drupal newcomer? Use our learning guide to become a guru!

Best Free Drupal Themes: Selection criteria

The main question when compiling the list of our proposed themes was how to make the comparison fair and objective. After much discussion, we decided that a theme must satisfy the following basic criteria for it to be considered in the list of top 10 Drupal themes:


  1. It must be free.

  2. It must run on either Drupal 7 or Drupal 8 (or better, both).

  3. It must be actively maintained and developed.

  4. It must be covered by the Drupal security advisory policy.
    Coverage under the policy does not guarantee that a theme is free of vulnerabilities. Rather, it means that the theme has been reviewed for any publicly known vulnerabilities by the Drupal security team.

  5. It must be for general purpose.
    Some Drupal themes are designed for specific industries, e.g., restaurant. For the purpose of this list, only general purpose themes are considered.

  6. It must be responsive.

A responsive theme adjusts its layout to accommodate different screen sizes and resolutions. This is a basic requirement for today's mobile platforms.

  1. It must run out-of-the-box.

There are themes, and there are theme frameworks (also known as base themes). A theme framework is like a blank canvas with tools which a theme developer uses to build a custom theme. The top 10 list only contains Drupal themes which one can use out-of-the-box as feature-complete themes.


In the course of conducting this study, it was observed that a small number of organizations have each generated a relatively large number of themes, albeit good ones, that are only marginally different. If an organization makes multiple but similar quality Drupal themes, only representative themes may be selected for inclusion in the following theme set. The individual or organization responsible for a theme is identified below in brackets.


Anyway, we have kept you in suspense for too long already. Based on the above criteria, the top 10 free Drupal themes are:


  • BlueMasters (by More than Themes)

  • Corporate Clean (by More than Themes)

  • Danland (by DanPros)

  • Business (by Devsaran)

  • Nexus (by Devsaran)

  • Zircon (by WeebPal)

  • Business Responsive Theme (by Zymphonies)

  • Drupal8 Zymphonies (by Zymphonies)

  • Fontfolio (by Marios Lublinski)

  • Integrity (by knackforge)


Below, we discuss each theme in more detail.



BlueMasters is a popular WordPress theme that has been ported to the Drupal platform by More Than Themes. We recommend this theme, not just on its features only, but that it is maintained by More Than Themes, a solid well-reputed organization in the Drupal community. The theme supports a maximum layout of 12 regions. A region is the primary layout unit to which a component block can be placed. Therefore, the more regions a theme supports, the more customizable it is. With this Drupal theme, you can display a slideshow on the front page, and partition information into either 2 or 3 columns on a web page. In addition, you can organize and access your contents via multi-level dropdown menus. BlueMasters, however, is only available on Drupal 7.

Corporate Clean


Like BlueMasters, Corporate Clean is a theme ported to Drupal by More Than Themes. We recommend this theme because it offers a unique feature that is missing in many free Drupal themes, namely, a color scheme selector. Most free themes have a fixed color scheme which means that you cannot change the color of a button or the page background. With Corporate Clean, you can adjust the color of some screen elements. This theme supports 1-column, 2-column as well as 3-column layout. Multi-level drop-down menus and slideshows are also supported. The Corporate Clean theme only runs on Drupal 7.



We recommend Danland because, among the Drupal themes on this top 10 list, it gives you the most flexibility to fine tune the layout of your web page. Specifically, it supports a maximum of 26 regions, the highest number on the list. The layout can have 1, 2, or 3 columns. Danland runs on Drupal 6, 7, and 8.



In terms of the major features, the Business theme is at par with other themes on the list. We recommend the theme because of the finer feature details. For example, the slideshow feature allows the display of up to 5 images. Note that some free Drupal themes only allow a maximum of 3. Also, the Business theme has a color module, which is missing in most free themes. You can specify one of 6 fixed colors for web components. The Business theme is available for Drupal 7 and 8. However, the Drupal 7 version is not responsive, and is currently in maintenance mode only. The Drupal 8 version, on the other hand, is being actively developed, and is fully responsive.



Nexus is arguably the most visually appealing theme on the top 10 list. The clean design together with the solid support by Devsaran, its maintainer organization, put Nexus on the list. The theme runs on both Drupal 7 and 8 with the Drupal 8 version being a pre-release version only. The layout can have a maximum of 15 regions, which is average on the top 10 list. You can specify a 1-column or 2-column design on the layout. The slideshow feature supports a maximum of 3 images.



If your Drupal website is rich in images, then you should definitely consider using Zircon as the theme. You will be delighted by its slideshow, slider, as well as carousel features. You can run Zircon on both Drupal 7 and 8. However, the current Drupal 8 version has remained as a release candidate since November 2015. The Zircon layout supports 18 regions in 3 columns.

Business Responsive

Not all themes on the top 10 list support Drupal 8. Even for those which do, some are in pre-release status only. If you are looking for a stable Drupal 8 theme, you should consider the Business Responsive theme which has reached the 1.0 stable release status. This theme supports 17 regions in 1-column, 2-column, or 3-column layouts. It also has a slider feature, but installing the feature requires some manual steps after installing the theme. This theme supports the use of social media icons for popular platforms such as Facebook, Twitter, Google+, LinkedIn, and Pinterest. You can install this theme on both Drupal 7 and 8.

Drupal8 Zymphonies



If you want a stable Drupal 8 theme that offers more bells and whistles than the Business Responsive theme, Drupal8 Zymphonies comes highly recommended. This theme is, fittingly, only available on Drupal 8. It shares many features with other themes on the top 10 list, such as multi-level menus and 1/2/3-column layout. It distinguishes itself by offering 22 regions for placing blocks, the second highest on the theme list. Also, you can customize the Zymphonies credit link, all supported social media links, and the title and description fields in the main banner.



If your website is multilingual, you should definitely consider Fontfolio because it offers easy setup for links to webpages in all supported languages. Like BlueMasters, this theme is a popular WordPress theme that has been ported to Drupal. Fontfolio can run on both Drupal 7 and 8. Note that some existing features of the Drupal 7 version are still under development for the Drupal 8 version. Fontfolio supports a maximum of only 8 regions in its layout, the fewest on the list. Yet, overall, it is a simple but elegant Drupal theme that includes a 2-column responsive design.



If you want a simple no-frills theme that just works out-of-the-box, Integrity may be your choice. It is a Drupal 8 only theme. Its feature set is, in general, at par with the rest of the themes. Integrity supports multi-level menus and slideshows that display up to 5 images. The layout includes a 3-column design. The theme has defined 17 regions into which Drupal blocks can be placed.

Summary & Conclusion

Drupal has a wealth of good free themes. Each of them is ideal for Drupal users who have relatively simple requirements and want to try something other than the default theme. If a free theme cannot fully satisfy your particular requirements, then you may want to use its premium alternative or even to hire a professional Drupal agency that can assist you with your needs.


Which theme do you like the most among our top 10 choices? Perhaps, you have your own favourite theme that is not on our list. What are the goals of your project and what kind of theme are you looking for? Share with us your thoughts in the comments section below!

Categories: Drupal

Glassdimly tech Blog: Config Management Roundup

23 July 2017 - 10:05pm

Quite the problem—Drupal config management on local and prod.

Drupal 8 can be quite punctilious: it will simply refuse to work if there's a mismatch between database and config objects on the filesystem.

So... how do we manage two sets of configurations—one for local, and one for production?

The Problem

I have modules like varnish installed on production that shouldn't be enabled on local, and modules that are enabled on local that shouldn't be enabled on production.

Categories: Drupal

Drupal Commerce: See what’s new in Drupal Commerce 2.0-rc1

21 July 2017 - 1:34pm

Eight months ago we launched the first beta version of Commerce 2.x for Drupal 8. Since then we’ve made 304 code commits by 58 contributors, and we've seen dozens of attractive, high-performing sites go live. We entered the release candidate phase this month with the packaging of Commerce 2.0-rc1 (release notes), the final part of our long and fruitful journey to a full 2.0.

Introducing a new Promotions UI:

Some of the most exciting updates this Summer center around our promotions system. This work represents a huge leap forward from Commerce 1.x, as we've made promotions first class citizens in core. They power a variety of discount types and coupons, and now that they are in core we can ensure the systems are designed to look and work well on both the front end and back end.

Read on to learn more about what's new in promotions, payment, taxes, and more...

Categories: Drupal

Glassdimly tech Blog: Responsive iframe in Drupal 8 from Client Embed Code

21 July 2017 - 10:27am

Nobody likes iframes. That's because you can't style their innards, and they aren't responsive... or are they?!?!

The first thing to know about here is the padding height hack. This allows you to set the height of an object relative to the width, because while height is always as a percentage of the container, padding height is as a percentage of width. So all you have to know is the ratio of height to width and you can make a thing that responsively scales.

Categories: Drupal

Glassdimly tech Blog: Parse HTML in Drupal 8 to Get Attributes

21 July 2017 - 9:50am

Often one finds oneself needing to parse HTML. Back in the day, we used regexes, and smoked inside. We didn't even know about caveman coders back then. Later, we'd use SimpleHtmlDom and mostly just swore when things didn't quite work as expected. Now, we use PHP's DomDocument, and in Drupal we create them using Drupal's HTML utility.

Categories: Drupal

Hook 42: Hook 42 goes to Washington!

21 July 2017 - 9:38am

Hook 42 is expanding our enterprise Drupal services to the public sector. It’s only logical that our next trek is to Drupal GovCon!

We are bringing some of our colorful San Francisco Bay Area love to DC. We will be sharing our knowledge about planning and managing migrations, as well as core site building layout technologies. The most exciting part of the conference will be meeting up with our east coast Drupal community and government friends in person.

Categories: Drupal

Anubavam Blog: Dependency injection and Service Containers

21 July 2017 - 4:43am
Dependency injection and Service Containers

A dependency is an object that can be used (a service). An injection is the passing of a dependency to a dependent object (a client) that would use it. The service is made part of the client's state. Passing the service to the client, rather than allowing a client to build or find the service, is the fundamental requirement of the pattern." Dependency injection is an advanced software design pattern and applying it will increase flexibility. Once you wrap your head around this pattern, you will be unstoppable.

A practical example of accessing services in objects using dependency injection

For the following example, let's assume we are creating a method that will use the service of A, we need to pull the dependencies of B and C into the plugin which we can use to inject whichever services we require.

  • Application needs A so:
  • Application gets A from the Container, so:
  • Container creates C
  • Container creates B and gives it C
  • Container creates A and gives it B
  • Application calls A
  • A calls B
  • B does something

Types of Dependency Injection

There are different types of Dependency Injection:

  • Constructor injection
  • Method injection
  • Setter and property injection
  • PHP callable injection

Constructor Injection

The DI container supports constructor injection with the help of type hints(Type hinting we can specify the expected data type) for constructor parameters. The type hints tell the container which classes or interfaces are dependent when it is used to create a new object. The container will try to get the instances of the dependent classes or interfaces and then inject them into the new object through the constructor.

Method Injection 

In constructor injection we saw that the dependent class will use the same concrete class for its entire lifetime. Now if we need to pass separate concrete class on each invocation of the method, we have to pass the dependency in the method only.

Setter & Property Injection

Now we have discussed two scenarios where in constructor injection we knew that the dependent class will use one concrete class for the entire lifetime. The second approach is to use the method injection where we can pass the concrete class object in the action method itself. But what if the responsibility of selection of concrete class and invocation of method are in separate places. In such cases we need property injection.

PHP Callable Injection

Container will use a registered PHP callable to build new instances of a class. Each time when yii\di\Container::get() is called, the corresponding callable will be invoked. The callable is responsible to resolve the dependencies and inject them appropriately to the newly created objects

Dependency Injection: Advantages & Disadvantages


Reducing the dependency to each other of objects in application.
Unit testing is made easier.
Loosely couple 
Promotes re-usability of code or objects in different applications
Promotes logical abstraction of components.


DI increases complexity, usually by increasing the number of classes since responsibilities are separated more, which is not always beneficial.
Code will be coupled to the dependency injection framework.
It takes time to learn
If misunderstood it can lead to more harm than good


Dependency injection is a very simple concept of decoupling your code and easier to read. By injecting dependencies to objects we can isolate their purpose and easily swap them with others. 

The service container is basically there to manage some classes. It keeps track of what a certain service needs before getting instantiated, does it for you and all you have to do is access the container to request that service. Using it the right way will save time and frustration, while Drupal developers will even make it easier for the layman. 


admin Fri, 07/21/2017 - 07:43 Drupal developer Drupal Application Development
Categories: Drupal

CiviCRM Blog: CiviProxy and CiviMcRestFace sprint in Bonn

21 July 2017 - 1:40am

CiviCooP and Systopia and Palasthotel have been working together on CiviProxy and CiviProxy. This blog is a round up of what we have achieved in the last couple of days. The first thing we have achieved is that we had fun and a very good work atmosphere. We made long days and made lots of progress.

What are CiviProxy and CiviMcRestFace?

CiviProxy is a script to act as an application firewall for CiviCRM. It could be used to put your civicrm in secure network. CiviProxy is the gatekeeper to which external systems, such as your website, connect (this is for example when a user signs a petition on your website and the website submits this data to your CiviCRM). CiviProxy will make sure the call is from the right place (ip-adress) and is only doing what allowed to do. 

CiviMcRestFace (CiviMRF) is a framework to be used in other systems (such as your external website) to connect to CiviCRM. The framework itself is divided in three parts: the abstract core (CMS/System independent), the core implementation (e.g. a Drupal 7 implementation), and lastly the module who is doing the actual submission (for example the cmrf_webform module which provides the functionality to submit a webform to CiviCRM).

What we have achieved:

  • Completed the documentation on CiviProxy:
  • Got a working drupal 7 module with CiviMcRestFace:
    • Completed screens for set up connection profiles (you can also provide the connection credentials through your module with an api; so that you can store them somewhere outside the database)
    • Completed screen for the call log (a call is submission to CiviCRM through CiviMcRestFace)
    • Added functionality to queue calls and run them in the background and added functionality to retry failed calls
    • Added a basic webform integration module to submit a webform to the CiviCRM Api
    • Added a rules integration module so that you can perform additional actions when a call succeeds or fails. Probably a use case is when a call fails you want to send the data by e-mail to the CiviCRM Administrator so that he or she can enter the data manually.
    • Added an example module so you can see how you could use the cmrf_core module in your durpal projects
    • Code:
  • Got a start with the drupal 8 module for CiviMcRestFace:


ToolsAPIArchitectureCiviCRMCommunityDocumentationDrupalDrupal 8Sprints
Categories: Drupal