You are here

public function MigrationGroupFormBase::exists in Migrate Tools 8

Same name and namespace in other branches
  1. 8.5 src/Form/MigrationGroupFormBase.php \Drupal\migrate_tools\Form\MigrationGroupFormBase::exists()
  2. 8.2 src/Form/MigrationGroupFormBase.php \Drupal\migrate_tools\Form\MigrationGroupFormBase::exists()
  3. 8.3 src/Form/MigrationGroupFormBase.php \Drupal\migrate_tools\Form\MigrationGroupFormBase::exists()
  4. 8.4 src/Form/MigrationGroupFormBase.php \Drupal\migrate_tools\Form\MigrationGroupFormBase::exists()

Checks for an existing migration group.

Parameters

string|int $entity_id: The entity ID.

array $element: The form element.

FormStateInterface $form_state: The form state.

Return value

bool TRUE if this format already exists, FALSE otherwise.

File

src/Form/MigrationGroupFormBase.php, line 128
Contains Drupal\migrate_tools\Form\MigrationGroupFormBase.

Class

MigrationGroupFormBase
Class MigrationGroupFormBase.

Namespace

Drupal\migrate_tools\Form

Code

public function exists($entity_id, array $element, FormStateInterface $form_state) {

  // Use the query factory to build a new migration group entity query.
  $query = $this->entityQueryFactory
    ->get('migration_group');

  // Query the entity ID to see if its in use.
  $result = $query
    ->condition('id', $element['#field_prefix'] . $entity_id)
    ->execute();

  // We don't need to return the ID, only if it exists or not.
  return (bool) $result;
}