Jake Vanderwerf
2026-08-25 3d25ad7de4fdbb3eba2cde2a62422e6be5d79a0a
inc/rest/routes/ContentTermsRoutes.php
@@ -1,8 +1,12 @@
<?php
namespace JVBase\rest\routes;
use JVBase\Instance;
use JVBase\managers\Cache;
use JVBase\managers\queue\executors\ContentTermExecutor;
use JVBase\managers\queue\Queue;
use JVBase\managers\queue\TypeConfig;
use JVBase\managers\Roles;
use JVBase\registrar\Registrar;
use JVBase\rest\Rest;
use JVBase\rest\Route;
@@ -31,12 +35,13 @@
 */
class ContentTermsRoutes extends Rest
{
   use Instance;
   protected string $taxonomy;
   protected Registrar $registrar;
   protected ?CustomTable $historyTable = null;
   protected ?CustomTable $requestsTable = null;
   public function __construct(string $taxonomy = '')
   //TODO: This needs some work. We need to move most logic into it's own manager class
   protected function __construct(string $taxonomy = '')
   {
      $this->taxonomy = jvbNoBase($taxonomy);
@@ -44,6 +49,7 @@
         $this->registrar = Registrar::getInstance($this->taxonomy);
         $this->cacheName = $this->taxonomy;
         parent::__construct();
         $this->cache = Cache::for($this->taxonomy, 'term', DAY_IN_SECONDS);
         $this->setupTables();
         $this->setupCacheConnections();
      }
@@ -53,7 +59,7 @@
   public function registerContentTermsExecutors():void
   {
      $registry = JVB()->queue()->registry();
      $registry = Queue::getInstance()->registry();
      $executor = new ContentTermExecutor();
      $taxonomies = Registrar::withFeature('is_content', 'term');
@@ -205,7 +211,7 @@
      }
      return user_can($userID, 'manage_options') ||
         JVB()->roles()->isManager($userID, $termID);
         Roles::getInstance()()->isManager($userID, $termID);
   }
   public function checkOwnerPermission(WP_REST_Request $request): bool
@@ -218,7 +224,7 @@
      }
      return user_can($userID, 'manage_options') ||
         JVB()->roles()->isOwner($userID, $termID);
         Roles::getInstance()()->isOwner($userID, $termID);
   }
   /**
@@ -233,7 +239,7 @@
      unset($data['user'], $data['term_id']);
      // Queue the update
      $op = JVB()->queue()->add(
      $op = Queue::getInstance()->add(
         "{$this->taxonomy}_update",
         $userID,
         array_merge(['term_id' => $termID], $data),
@@ -306,7 +312,7 @@
      $targetUserID = (int)$request->get_param('target_user');
      // Queue the operation
      $op = JVB()->queue()->add(
      $op = Queue::getInstance()->add(
         "{$this->taxonomy}_member_{$action}",
         $userID,
         [
@@ -469,7 +475,7 @@
         });
         // Notify user
         JVB()->notification()->addNotification(
         NotificationManager::getInstance()->addNotification(
            $requestData['user_id'],
            'request_' . $status,
            [
@@ -508,7 +514,7 @@
         return $this->error('Invalid target user');
      }
      $roleManager = JVB()->roles();
      $roleManager = Roles::getInstance()();
      try {
         $result = match($role) {
@@ -548,13 +554,13 @@
    */
   protected function notifyTermManagers(int $termID, int $actingUserID, string $notificationType): void
   {
      $roleManager = JVB()->roles();
      $roleManager = Roles::getInstance()();
      $managers = $roleManager->getManagedTerms($actingUserID, $this->taxonomy);
      $term = get_term($termID, jvbCheckBase($this->taxonomy));
      foreach ($managers as $managerID) {
         JVB()->notification()->addNotification(
         NotificationManager::getInstance()->addNotification(
            $managerID,
            $notificationType,
            [