Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Make Some operations Programmatically - Hook Update Deploy Tools

By editor , 11 January, 2017
Question

How to make deploy operations programmatically ?

Hook Update Deploy Tools is a great contrib module help to make most of site deploy operations programmatically.
Link : https://www.drupal.org/project/hook_update_deploy_tools

CAUTION : Current drupal 8 version is unstable (8.x-1.0-unstable1, 2016-Feb-07 Version),  but 8.x-1.x-dev version is usable.

Example: Delete a field instance.
Using contrib module hook_update_deploy_tools

//Drupal 8:
$message = \HookUpdateDeployTools\Fields::deleteInstance('taxonomy_term', 'field_name', 'tags');

//Drupal 7:  
$message = HookUpdateDeployTools\Fields::deleteInstance('taxonomy_term', 'field_name', 'tags');

 

Without Hook Update Deploy Tools
//Drupal 8:

//Drupal 7:
$instance = field_info_instance('node', 'field_name', 'page');//For node
$instance = field_info_instance('taxonomy_term', 'field_name', 'tags');//For taxonomy term
if ($instance) {
  field_delete_instance($instance);
}

//D8 (Not tested)
$field_info = \Drupal\field\Entity\FieldConfig::loadByName('node', 'page', 'field_name');
$field_info->delete();

Tags

  • Drupal 8
  • Code
  • Drupal 7
  • Module
Change Drupal 8 text field maximum length
Custom Content Entity Field types of drupal 8

Comments

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer