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/managers/queue/executors/ContentTermExecutor.php | 82 ++++++++++++++++++++---------------------
1 files changed, 40 insertions(+), 42 deletions(-)
diff --git a/inc/managers/queue/executors/ContentTermExecutor.php b/inc/managers/queue/executors/ContentTermExecutor.php
index bac1179..0592fb1 100644
--- a/inc/managers/queue/executors/ContentTermExecutor.php
+++ b/inc/managers/queue/executors/ContentTermExecutor.php
@@ -2,13 +2,14 @@
namespace JVBase\managers\queue\executors;
use JVBase\managers\CustomTable;
+use JVBase\managers\NotificationManager;
use JVBase\managers\queue\Executor;
use JVBase\managers\queue\Operation;
use JVBase\managers\queue\Progress;
use JVBase\managers\queue\Result;
-use JVBase\managers\RoleManager;
+use JVBase\managers\Roles;
use JVBase\meta\Meta;
-use JVBase\utility\Features;
+use JVBase\registrar\Registrar;
use Exception;
if (!defined('ABSPATH')) {
@@ -25,20 +26,21 @@
*/
class ContentTermExecutor implements Executor
{
- protected RoleManager $roleManager;
+ protected Roles $roleManager;
public function __construct()
{
- $this->roleManager = new RoleManager();
+ $this->roleManager = new Roles();
}
public function execute(Operation $operation, Progress $progress): Result
{
+ error_log('Executing Content Term.... ');
// Extract taxonomy from operation type (e.g., "shop_update" -> "shop")
- $parts = explode('_', $operation->type);
- $taxonomy = $parts[0] ?? '';
-
- if (!$taxonomy || !isset(JVB_TAXONOMY[$taxonomy])) {
+ $data= $operation->requestData;
+ $taxonomy = $data['taxonomy']??false;
+ $registrar = $taxonomy? Registrar::getInstance($taxonomy) : false;
+ if (!$taxonomy || !$registrar) {
return Result::fail("Invalid taxonomy: {$taxonomy}");
}
@@ -73,7 +75,7 @@
unset($data['term_id']);
// Filter to only allowed fields
- $allowed = jvbGetFields($taxonomy, 'term');
+ $allowed = Registrar::getFieldsFor($taxonomy);
$setData = array_filter(
$data,
fn($key) => array_key_exists($key, $allowed),
@@ -85,13 +87,9 @@
}
// Update metadata
- $meta->setAll($setData);
- $results = $meta->save();
+ $results = $meta->setAll($setData);
if ($results) {
- // Trigger any post-update actions (e.g., thumbnail generation)
- do_action(BASE . "{$taxonomy}_updated", $termID, $userID, $setData);
-
return Result::success([
'updated_fields' => array_keys($setData),
'term_id' => $termID
@@ -128,7 +126,8 @@
}
// Check if tracking enabled
- if (!Features::forTaxonomy($taxonomy)->has('track_changes')) {
+ $registrar = Registrar::getInstance($taxonomy);
+ if ($registrar && !$registrar->hasFeature('track_changes')) {
return Result::fail('Member tracking not enabled for ' . $taxonomy);
}
@@ -173,15 +172,18 @@
*/
protected function addMember(int $userID, int $termID, string $taxonomy): Result
{
- $config = JVB_TAXONOMY[$taxonomy] ?? [];
- $content = $config['for_content'] ?? [];
+ $registrar = Registrar::getInstance($taxonomy);
+ if (!$registrar) {
+ return Result::fail('No content registered');
+ }
- if (empty($content)) {
+ $forContent = $registrar->registrar->for;
+ if (empty($forContent)) {
return Result::fail('No content types configured for ' . $taxonomy);
}
// Get table name (e.g., "history_artist_shop")
- $contentType = $content[0]; // Use first content type
+ $contentType = is_array($forContent) ? $forContent[0] : $forContent; // Use first content type
$tableName = "history_{$contentType}_{$taxonomy}";
$table = CustomTable::for($tableName);
@@ -235,9 +237,6 @@
throw new Exception('Failed to set taxonomy term: ' . $termResult->get_error_message());
}
- // Clear cache
- JVB()->cache()->for($taxonomy)->delete("{$taxonomy}_{$termID}_members");
-
// Notify term managers
$this->notifyTermManagers($termID, $userID, $taxonomy, 'member_added');
@@ -254,15 +253,19 @@
*/
protected function removeMember(int $userID, int $termID, string $taxonomy): Result
{
- $config = JVB_TAXONOMY[$taxonomy] ?? [];
- $content = $config['for_content'] ?? [];
+ $registrar = Registrar::getInstance($taxonomy);
+ if (!$registrar) {
+ return Result::fail('No content registered');
+ }
+ $forContent = $registrar->registrar->for;
- if (empty($content)) {
+ if (empty($forContent)) {
return Result::fail('No content types configured for ' . $taxonomy);
}
// Get table name
- $contentType = $content[0];
+ $contentType = is_array($forContent) ? $forContent[0] : $forContent;
+
$tableName = "history_{$contentType}_{$taxonomy}";
$table = CustomTable::for($tableName);
@@ -296,9 +299,6 @@
throw new Exception('Failed to remove taxonomy term: ' . $termResult->get_error_message());
}
- // Clear cache
- JVB()->cache()->for($taxonomy)->delete("{$taxonomy}_{$termID}_members");
-
// Notify term managers
$this->notifyTermManagers($termID, $userID, $taxonomy, 'member_removed');
@@ -319,18 +319,16 @@
$term = get_term($termID, jvbCheckBase($taxonomy));
$user = get_userdata($userID);
- foreach ($managers as $managerID) {
- JVB()->notification()->addNotification(
- $managerID,
- $notificationType,
- [
- 'user_id' => $userID,
- 'user_name' => $user ? $user->display_name : 'Unknown',
- 'term_id' => $termID,
- 'term_name' => $term && !is_wp_error($term) ? $term->name : 'Unknown',
- 'taxonomy' => $taxonomy
- ]
- );
- }
+ //TODO: Check this
+ NotificationManager::getInstance()->notify(
+ $managers,
+ $notificationType,
+ $userID,
+ [
+ 'target_id' => $termID,
+ 'target_type' => $taxonomy
+ ]
+ );
+
}
}
--
Gitblit v1.10.0