DatabaseStorageList.php in Key-value Extensions 8
File
src/KeyValueStore/DatabaseStorageList.php
View source
<?php
namespace Drupal\key_value\KeyValueStore;
class DatabaseStorageList extends DatabaseStorageSortedBase implements KeyValueStoreListInterface {
public function delete($count, $value) {
}
public function pop() {
}
public function push($value) {
$this
->pushMultiple([
$value,
]);
}
public function pushMultiple(array $values) {
foreach ($values as $value) {
$sub_query = $this->connection
->select($this->table, 't')
->condition('t.collection', $this->collection);
$sub_query
->addExpression(':collection', 'collection', [
':collection' => $this->collection,
]);
$sub_query
->addExpression('IFNULL(MAX(t.name) + 1, 0)', 'name');
$sub_query
->addExpression(':value', 'value', [
':value' => $this->serializer
->encode($value),
]);
$this->connection
->insert($this->table)
->from($sub_query)
->execute();
}
}
public function set($key, $value) {
$this->connection
->update($this->table)
->fields([
'value' => $this->serializer
->encode($value),
])
->condition('collection', $this->collection)
->condition('name', (int) $key)
->execute();
}
public function shift() {
}
public function unshift($value) {
}
public function unshiftMultiple(array $values) {
}
}