You are here

protected function DeleteFolderForm::check_term_is_deletable in Taxonomy File Tree 8

Same name and namespace in other branches
  1. 3.x src/Form/DeleteFolderForm.php \Drupal\tft\Form\DeleteFolderForm::check_term_is_deletable()

Check if the term has no files or child terms.

1 call to DeleteFolderForm::check_term_is_deletable()
DeleteFolderForm::buildForm in src/Form/DeleteFolderForm.php
Form constructor.

File

src/Form/DeleteFolderForm.php, line 19

Class

DeleteFolderForm
Delete a term form.

Namespace

Drupal\tft\Form

Code

protected function check_term_is_deletable($tid) {

  /** @var \Drupal\taxonomy\TermStorage $storage */
  $storage = \Drupal::entityTypeManager()
    ->getStorage('taxonomy_term');
  $terms = $storage
    ->loadTree('tft_tree', $tid, 1);
  if (!empty($terms)) {
    return FALSE;
  }
  $fids = \Drupal::entityQuery('media')
    ->condition('bundle', 'tft_file')
    ->condition('tft_folder.target_id', $tid)
    ->execute();
  if (!empty($fids)) {
    return FALSE;
  }
  return TRUE;
}