QueueDatabaseFactory.php 935 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Drupal\Core\Queue;
  3. use Drupal\Core\Database\Connection;
  4. /**
  5. * Defines the key/value store factory for the database backend.
  6. */
  7. class QueueDatabaseFactory {
  8. /**
  9. * The database connection.
  10. *
  11. * @var \Drupal\Core\Database\Connection
  12. */
  13. protected $connection;
  14. /**
  15. * Constructs this factory object.
  16. *
  17. * @param \Drupal\Core\Database\Connection $connection
  18. * The Connection object containing the key-value tables.
  19. */
  20. public function __construct(Connection $connection) {
  21. $this->connection = $connection;
  22. }
  23. /**
  24. * Constructs a new queue object for a given name.
  25. *
  26. * @param string $name
  27. * The name of the collection holding key and value pairs.
  28. *
  29. * @return \Drupal\Core\Queue\DatabaseQueue
  30. * A key/value store implementation for the given $collection.
  31. */
  32. public function get($name) {
  33. return new DatabaseQueue($name, $this->connection);
  34. }
  35. }