Loading src/UsageDataDatabaseStorage.php +22 −11 Original line number Diff line number Diff line Loading @@ -93,10 +93,9 @@ class UsageDataDatabaseStorage implements UsageDataStorageInterface { /** * {@inheritdoc} */ public function fetchUsageData($type, $eventType = NULL, $entityTypeId = NULL, $entityId = NULL, $count = TRUE, $conditions = []) { public function fetchUsageQuery($type, $eventType = NULL, $entityTypeId = NULL, $entityId = NULL) { // Make sure the table exists. $table = $this->tableName($type); if ($this->connection->schema()->tableExists($table)) { $query = $this->connection->select($table, 'u'); if ($eventType) { Loading @@ -109,6 +108,18 @@ class UsageDataDatabaseStorage implements UsageDataStorageInterface { $query->condition('entity_id', $entityId); } return $query; } /** * {@inheritdoc} */ public function fetchUsageData($type, $eventType = NULL, $entityTypeId = NULL, $entityId = NULL, $count = TRUE, $conditions = []) { // Make sure the table exists. $table = $this->tableName($type); if ($this->connection->schema()->tableExists($table)) { $query = $this->fetchUsageQuery($type, $eventType, $entityTypeId, $entityId); if (!$count) { // @todo this could be configurable, just grab all for now. $query->fields('u'); Loading src/UsageDataStorageInterface.php +21 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,27 @@ interface UsageDataStorageInterface { */ public function recordUsageByType($type, array $data); /** * Fetches usage data query for the appropriate table. * * NOTE: This function does NOT provide the fields() call as the entire * purpose is to allow altering of the query. Without adding this method * you will not be able to execute. * * @param string $type * The type of usage data to fetch. * @param string $eventType * The optional event type. * @param string $entityTypeId * The optional entity type id. * @param string $entityId * The optional entity id. * * @return \Drupal\Core\Database\Query\SelectInterface * The query for the usage type. */ public function fetchUsageQuery($type, $eventType = NULL, $entityTypeId = NULL, $entityId = NULL); /** * Fetches usage data from the appropriate table. * Loading Loading
src/UsageDataDatabaseStorage.php +22 −11 Original line number Diff line number Diff line Loading @@ -93,10 +93,9 @@ class UsageDataDatabaseStorage implements UsageDataStorageInterface { /** * {@inheritdoc} */ public function fetchUsageData($type, $eventType = NULL, $entityTypeId = NULL, $entityId = NULL, $count = TRUE, $conditions = []) { public function fetchUsageQuery($type, $eventType = NULL, $entityTypeId = NULL, $entityId = NULL) { // Make sure the table exists. $table = $this->tableName($type); if ($this->connection->schema()->tableExists($table)) { $query = $this->connection->select($table, 'u'); if ($eventType) { Loading @@ -109,6 +108,18 @@ class UsageDataDatabaseStorage implements UsageDataStorageInterface { $query->condition('entity_id', $entityId); } return $query; } /** * {@inheritdoc} */ public function fetchUsageData($type, $eventType = NULL, $entityTypeId = NULL, $entityId = NULL, $count = TRUE, $conditions = []) { // Make sure the table exists. $table = $this->tableName($type); if ($this->connection->schema()->tableExists($table)) { $query = $this->fetchUsageQuery($type, $eventType, $entityTypeId, $entityId); if (!$count) { // @todo this could be configurable, just grab all for now. $query->fields('u'); Loading
src/UsageDataStorageInterface.php +21 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,27 @@ interface UsageDataStorageInterface { */ public function recordUsageByType($type, array $data); /** * Fetches usage data query for the appropriate table. * * NOTE: This function does NOT provide the fields() call as the entire * purpose is to allow altering of the query. Without adding this method * you will not be able to execute. * * @param string $type * The type of usage data to fetch. * @param string $eventType * The optional event type. * @param string $entityTypeId * The optional entity type id. * @param string $entityId * The optional entity id. * * @return \Drupal\Core\Database\Query\SelectInterface * The query for the usage type. */ public function fetchUsageQuery($type, $eventType = NULL, $entityTypeId = NULL, $entityId = NULL); /** * Fetches usage data from the appropriate table. * Loading