You are here

entity_hierarchy.drush.inc in Entity Reference Hierarchy 3.x

Same filename and directory in other branches
  1. 8.2 entity_hierarchy.drush.inc

Contains drush commands for the module.

File

entity_hierarchy.drush.inc
View source
<?php

/**
 * @file
 * Contains drush commands for the module.
 */

/**
 * Implements hook_drush_command().
 */
function entity_hierarchy_drush_command() {
  $items = [];
  $items['entity-hierarchy-rebuild-tree'] = [
    'description' => 'Rebuild tree.',
    'arguments' => [
      'field_name' => dt('Field machine name'),
      'entity_type_id' => dt('Entity type id'),
    ],
    'options' => [],
    'examples' => [
      'drush entity-hierarchy-rebuild-tree field_parents node' => 'Rebuild tree for node field named field_parents.',
    ],
  ];
  return $items;
}

/**
 * Rebuild the tree.
 */
function drush_entity_hierarchy_rebuild_tree($field_name, $entity_type_id) {
  $tasks = \Drupal::service('entity_hierarchy.tree_rebuilder')
    ->getRebuildTasks($field_name, $entity_type_id);
  batch_set($tasks);
  $batch =& batch_get();
  $batch['progressive'] = FALSE;
  drush_backend_batch_process();
}

Functions

Namesort descending Description
drush_entity_hierarchy_rebuild_tree Rebuild the tree.
entity_hierarchy_drush_command Implements hook_drush_command().