From a9654f00c8fbc9934289d761843ddd071025013f Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 28 Aug 2026 17:20:28 +0000
Subject: [PATCH] =PHPStorm Code Inspection: fixed class reference errors (from getting rid of JVB() and replacing with direct class::getInstance; as well as general code sniffing, etc

---
 inc/rest/routes/Invitations.php |   38 +++++++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/inc/rest/routes/Invitations.php b/inc/rest/routes/Invitations.php
index 6322115..558f118 100644
--- a/inc/rest/routes/Invitations.php
+++ b/inc/rest/routes/Invitations.php
@@ -1,6 +1,11 @@
 <?php
 namespace JVBase\rest\routes;
 
+use JVBase\Instance;
+use JVBase\managers\Cache;
+use JVBase\managers\InvitationsManager;
+use JVBase\managers\queue\Queue;
+use JVBase\managers\Roles;
 use JVBase\rest\Rest;
 use JVBase\managers\CustomTable;
 use JVBase\rest\Route;
@@ -20,22 +25,21 @@
  */
 class Invitations extends Rest
 {
+	use Instance;
 	protected array $inviteConfig;
 	protected CustomTable $table;
-
+	protected Cache $termCache;
 	public function __construct()
 	{
 		$this->cacheName = 'invitations';
 		parent::__construct();
+		$this->cache = Cache::for('invitations_posts','post');
+		$this->termCache = Cache::for('invitation_terms', 'term');
 
 		// Get invitation configuration
-		$this->inviteConfig = JVB()->invitations()->getInviteConfig();
+		$this->inviteConfig = InvitationsManager::getInstance()->getInviteConfig();
 		$this->table = CustomTable::for('invitations');
 
-		// Cache connections
-		$this->cache
-			->connect('user')
-			->connect('taxonomy');
 	}
 
 	public function registerRoutes(): void
@@ -77,7 +81,7 @@
 		}
 
 		$args = [
-			'user' => $userID,
+			'id' => $userID,
 			'to_term' => $termID,
 			'taxonomy' => $taxonomy ? jvbNoBase($taxonomy) : null,
 			'status' => $request->get_param('status'),
@@ -85,8 +89,8 @@
 		];
 
 		// Check cache
-		$key = $this->cache->generateKey($args);
-		if ($cached = $this->cache->get($key)) {
+
+		if ($cached = $this->cache->get($args)) {
 			return $this->success($cached);
 		}
 
@@ -96,7 +100,7 @@
 			: $this->getUserInvitations($args);
 
 		// Cache result
-		$this->cache->set($key, $result);
+		$this->cache->set($args, $result);
 
 		return $this->success($result);
 	}
@@ -104,10 +108,10 @@
 	/**
 	 * Get invitations for a specific term
 	 */
-	protected function getTermInvitations(array $args): array
+	public function getTermInvitations(array $args): array
 	{
 		// Check permission
-		if (!JVB()->roles()->isManager($args['user'], $args['to_term'])) {
+		if (!Roles::getInstance()()->isManager($args['user'], $args['to_term'])) {
 			return $this->forbidden('You cannot view invitations for this ' . $args['taxonomy'])->get_data();
 		}
 
@@ -213,7 +217,7 @@
 		}
 
 		// Queue using fluent interface
-		$op = JVB()->queue()->add(
+		$op = Queue::getInstance()->add(
 			'invitation_create',
 			$userID,
 			['invitations' => $validated],
@@ -231,7 +235,7 @@
 	 */
 	protected function validateInvitations(int $userID, array $invites): array
 	{
-		return JVB()->invitations()->validateInvitations($userID, $invites);
+		return InvitationsManager::getInstance()->validateInvitations($userID, $invites);
 	}
 
 
@@ -248,7 +252,7 @@
 			return $this->error('Invitation ID required');
 		}
 
-		$op = JVB()->queue()->add(
+		$op = Queue::getInstance()->add(
 			'invitation_revoke',
 			$userID,
 			['invitation_id' => $invitationID],
@@ -269,7 +273,7 @@
 			return $this->error('Invitation ID required');
 		}
 
-		$op = JVB()->queue()->add(
+		$op = Queue::getInstance()->add(
 			'invitation_resend',
 			$userID,
 			['invitation_id' => $invitationID],
@@ -308,7 +312,7 @@
 		];
 
 		// Add term information if present
-		foreach (JVB()->roles()->getInvitableTaxonomies() as $taxonomy) {
+		foreach (Roles::getInstance()()->getInvitableTaxonomies() as $taxonomy) {
 			$column = 'to_' . $taxonomy;
 			if (isset($invitation->$column) && $invitation->$column) {
 				$termID = (int) $invitation->$column;

--
Gitblit v1.10.0