You are here

public function MigrationFormBase::exists in Migrate Tools 8

Same name and namespace in other branches
  1. 8.5 src/Form/MigrationFormBase.php \Drupal\migrate_tools\Form\MigrationFormBase::exists()
  2. 8.2 src/Form/MigrationFormBase.php \Drupal\migrate_tools\Form\MigrationFormBase::exists()
  3. 8.3 src/Form/MigrationFormBase.php \Drupal\migrate_tools\Form\MigrationFormBase::exists()
  4. 8.4 src/Form/MigrationFormBase.php \Drupal\migrate_tools\Form\MigrationFormBase::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/MigrationFormBase.php, line 138
Contains Drupal\migrate_tools\Form\MigrationFormBase.

Class

MigrationFormBase
Class MigrationFormBase.

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 entity query.
  $query = $this->entityQueryFactory
    ->get('migration');

  // 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;
}