Drupal Helper Utility

Categories

Component ID

2784647

Component name

Drupal Helper Utility

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

6791

Component created

Component changed

Component body

Development of this project takes place on Github.

A library of Drupal-related PHP helpers for Drupal 7 core and contrib modules.

Functionality

  • Bean
    • Create or load a bean.
  • Block
    • Render a block.
    • Place or remove a block in/from a region using core block module.
    • Set the block visibility.
  • Entity
    • Get label for entity bundle.
  • Feature
    • Revert a feature.
  • Field
    • Delete a field.
    • Delete an instance of a field.
  • Form
    • Get default values from the form.
  • General
    • Print CLI and web messages.
  • Menu
    • Add, update, delete and find menu items in specified menu.
  • Module
    • Enable, disable or uninstall a module.
  • Random
    • Generate random: string, name, IP address, phone number, email, date of birth, path.
    • Get random array items.
  • System
    • Get or set the weight of the module, theme or profile.
    • Check the status of the module, theme or profile.
  • Taxonomy
    • Create form element options from terms in provided vocabulary.
  • Theme
    • Set a theme as the default or admin theme.
    • Enable or disable a theme.
  • User
    • Create user with specified fields and roles.
  • Utility
    • Recursively remove empty elements from array.
    • Retrieve array column.

Usage

Use the Drupal helpers classes to perform common tasks during your Drupal module updates.

<?php

/**
 * @file
 * example.install uninstall and update implementations.
 */

use Drupaldrupal_helpersModule;
use Drupaldrupal_helpersFeature;
use Drupaldrupal_helpersGeneral;

/**
 * Enable Views and Revert 'mysite' features.
 */
function example_update_7001 () {
  // Enable views.
  Module::enable('views');

  // Revert mysite features.
  Feature::revert('mysite_features');

  // Print My message.
  General::messageSet('My message');
}

Dependencies