_init(self::QUEUE_POISON_PILL_TABLE, 'version'); } /** * @inheritdoc */ public function put(): string { $connection = $this->getConnection(); $table = $this->getMainTable(); $uuid = uniqid('version-'); $version = $this->getVersionFromDb(); if ($version !== '') { $connection->update($table, ['version' => $uuid]); } else { $connection->insert($table, ['version' => $uuid]); } return $uuid; } /** * @inheritdoc */ public function getLatestVersion(): string { return $this->getVersionFromDb(); } /** * Returns version form DB or null. * * @return string */ private function getVersionFromDb(): string { $select = $this->getConnection()->select()->from( $this->getTable(self::QUEUE_POISON_PILL_TABLE), 'version' ); $result = $this->getConnection()->fetchOne($select); return (string)$result; } }