You are here

class EntityHierarchyCommands in Entity Reference Hierarchy 3.x

Same name and namespace in other branches
  1. 8.2 src/Commands/EntityHierarchyCommands.php \Drupal\entity_hierarchy\Commands\EntityHierarchyCommands

Drush commands.

Hierarchy

Expanded class hierarchy of EntityHierarchyCommands

1 string reference to 'EntityHierarchyCommands'
drush.services.yml in ./drush.services.yml
drush.services.yml
1 service uses EntityHierarchyCommands
entity_hierarchy.commands in ./drush.services.yml
\Drupal\entity_hierarchy\Commands\EntityHierarchyCommands

File

src/Commands/EntityHierarchyCommands.php, line 10

Namespace

Drupal\entity_hierarchy\Commands
View source
class EntityHierarchyCommands extends DrushCommands {

  /**
   * TreeRebuilder instance.
   *
   * @var \Drupal\entity_hierarchy\Storage\TreeRebuilder
   */
  protected $treeRebuilder;

  /**
   * EntityHierarchyCommands constructor.
   *
   * @param \Drupal\entity_hierarchy\Storage\TreeRebuilder $treeRebuilder
   */
  public function __construct($treeRebuilder) {
    parent::__construct();
    $this->treeRebuilder = $treeRebuilder;
  }

  /**
   * Rebuild tree.
   *
   * @param string $field_name
   *   Field machine name
   * @param string $entity_type_id
   *   Entity type id
   *
   * @usage drush entity-hierarchy:rebuild-tree field_parents node
   *   Rebuild tree for node field named field_parents.
   *
   * @command entity-hierarchy:rebuild-tree
   * @aliases entity-hierarchy-rebuild-tree
   */
  public function hierarchyRebuildTree($field_name, $entity_type_id) {
    $tasks = $this->treeRebuilder
      ->getRebuildTasks($field_name, $entity_type_id);
    batch_set($tasks);
    $batch =& batch_get();
    $batch['progressive'] = FALSE;
    drush_backend_batch_process();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityHierarchyCommands::$treeRebuilder protected property TreeRebuilder instance.
EntityHierarchyCommands::hierarchyRebuildTree public function Rebuild tree.
EntityHierarchyCommands::__construct public function EntityHierarchyCommands constructor.