| | |
| | | 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\registrar\Registrar; |
| | | use Exception; |
| | |
| | | */ |
| | | 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") |
| | | $data= $operation->requestData; |
| | | $taxonomy = $data['taxonomy']??false; |
| | |
| | | } |
| | | |
| | | // 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 |
| | |
| | | $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 |
| | | ] |
| | | ); |
| | | |
| | | } |
| | | } |