function PoDatabaseWriter::writeItems

Same name and namespace in other branches
  1. 9 core/modules/locale/src/PoDatabaseWriter.php \Drupal\locale\PoDatabaseWriter::writeItems()
  2. 8.9.x core/modules/locale/src/PoDatabaseWriter.php \Drupal\locale\PoDatabaseWriter::writeItems()
  3. 10 core/modules/locale/src/PoDatabaseWriter.php \Drupal\locale\PoDatabaseWriter::writeItems()

Writes all or the given amount of items.

Parameters

PoReaderInterface $reader: Reader to read PoItems from.

int $count: Amount of items to read from $reader to write. If -1, all items are read from $reader.

Overrides PoWriterInterface::writeItems

File

core/modules/locale/src/PoDatabaseWriter.php, line 200

Class

PoDatabaseWriter
Gettext PO writer working with the locale module database.

Namespace

Drupal\locale

Code

public function writeItems(PoReaderInterface $reader, $count = -1) {
  // Processing multiple writes in a transaction is quicker than committing
  // each individual write.
  $transaction = \Drupal::database()->startTransaction();
  $forever = $count == -1;
  while (($count-- > 0 || $forever) && ($item = $reader->readItem())) {
    $this->writeItem($item);
  }
  // Commit the transaction.
  unset($transaction);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.