You are here

public function FormAssemblyStorage::disableInactive in FormAssembly 8

Sets status 0 for all faid not in the active array.

Parameters

array $faidEnabled: The name of the entity property.

Throws

\Drupal\Core\Entity\EntityStorageException

File

src/FormAssemblyStorage.php, line 31

Class

FormAssemblyStorage
Entity storage class FormAssemblyStorage.

Namespace

Drupal\formassembly

Code

public function disableInactive(array $faidEnabled) {
  $query = $this->database
    ->select($this->baseTable, 'fa');
  $query
    ->addField('fa', 'id');
  $query
    ->condition('faid', $faidEnabled, 'NOT IN');
  $missingForms = $query
    ->execute()
    ->fetchCol();
  $toDisable = $this
    ->loadMultiple($missingForms);
  foreach ($toDisable as $entity) {

    /** @var \Drupal\formassembly\Entity\FormAssemblyEntity $entity */
    $entity
      ->disable()
      ->save();
  }
}