3 namespace Drupal\advagg\State;
5 use Drupal\Core\State\State as CoreState;
8 * Provides AdvAgg State interfaces with a few extra commands.
10 abstract class State extends CoreState {
13 * If the array isn't keyed by filepath the column the filepath is stored in.
15 protected $pathColumn = NULL;
18 * Gets all stored information from this Key Value Store.
21 * An array of all key value pairs.
23 public function getAll() {
24 $values = $this->keyValueStore->getAll();
29 * Delete all stored information from this Key Value Store.
31 public function deleteAll() {
32 $this->keyValueStore->deleteAll();
36 * Get a semi-random (randomness not guaranteed) key.
38 public function getRandomKey() {
39 $key = array_rand($this->getAll());
44 * Get a semi-random (randomness not guaranteed) value.
46 public function getRandom() {
47 return $this->get($this->getRandomKey());
51 * Scan the filesystem for missing files and removee from database.
53 public function clearMissingFiles() {
55 $values = $this->getAll();
59 if ($this->pathColumn) {
60 $values = array_column($values, NULL, $this->pathColumn);
62 foreach ($values as $path => $details) {
63 if (!file_exists($path)) {
64 $removed[$path] = $values[$path];