From a6413da67a4579866f0fd0323ddb23a7b6b9654a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 18 Sep 2026 17:00:53 +0000
Subject: [PATCH] =Cleaning up the Integrations setup a bit, started the Helcim integration work too

---
 inc/managers/DirectoryManager.php |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/inc/managers/DirectoryManager.php b/inc/managers/DirectoryManager.php
index 4645f97..c3e2010 100644
--- a/inc/managers/DirectoryManager.php
+++ b/inc/managers/DirectoryManager.php
@@ -5,6 +5,8 @@
 	exit;
 }
 
+use JVBase\Instance;
+use JVBase\integrations\services\Umami;
 use JVBase\registrar\Registrar;
 use JVBase\base\Site;
 use WP_Block;
@@ -12,6 +14,7 @@
 
 class DirectoryManager
 {
+	use Instance;
     protected array $directories;
     protected array $directoryPageIDs;
 	protected array $directoryList;
@@ -20,7 +23,7 @@
     protected static string $slug = BASE.'for_type_slug';
     protected Cache $cache;
 
-    public function __construct($perPage = 100)
+    private function __construct($perPage = 100)
     {
 		$this->directories = $this->getDirectories();
         if (empty($this->directories)) {
@@ -28,19 +31,22 @@
         }
 		$this->perPage = $perPage;
         $this->cache = Cache::for('directory', WEEK_IN_SECONDS);
-		$this->cache->connect('post', true)
-			->connect('taxonomy', true)
-			->connect('user', true);
 
-		if (JVB_TESTING) {
-			$this->cache->flush();
-		}
+
 
 		jvb_register_do_once('buildDirectories', [$this, 'activate']);
 		add_action('init', [$this, 'registerDirectories']);
         add_filter('pre_render_block', [$this, 'renderBlock'], 20, 3);
+		add_action('save_post', [$this, 'flushPostCache']);
+		add_action('edit_terms', [$this, 'flushPostCache']);
     }
 
+	public function flushPostCache(int $postID):void
+	{
+		//TODO: We can probably use a bit more finesse here.
+		$this->cache->flush();
+	}
+
     public function registerDirectories():void
     {
 
@@ -66,7 +72,7 @@
 			'public'              => true,
 			'menu_icon'		=> jvbCSSIcon('list-dashes'),
 			'publicly_queryable'    => true,
-			'show_in_menu'          => true,
+			'show_in_menu'          => false,
 			'show_in_admin_bar'     => false,
 			'has_archive'           => true,
 			'hierarchical'			=> true,
@@ -90,21 +96,21 @@
 			$directories = [];
 			//content
 
-			$content = Registrar::getFeatured('show_directory', 'post');
+			$content = Registrar::withFeature('show_directory', 'post');
 			if(!empty($content)) {
 				foreach ($content as $key) {
 					$directories[$key] = 'content';
 				}
 			}
 
-			$taxonomies = Registrar::getFeatured('show_directory', 'term');
+			$taxonomies = Registrar::withFeature('show_directory', 'term');
 			if(!empty($taxonomies)) {
 				foreach ($taxonomies as $key) {
 					$directories[$key] = 'taxonomy';
 				}
 			}
 
-			$users = Registrar::getFeatured('show_directory', 'user');
+			$users = Registrar::withFeature('show_directory', 'user');
 			if(!empty($users)) {
 				foreach ($users as $key) {
 					$directories[$key] = 'user';
@@ -673,7 +679,7 @@
     public function renderLettersList(array $list, string $type):string
     {
 
-        $umami = JVB()->connect('umami');
+        $umami = Umami::getInstance();
 
         $out = '<ul class="list-none">';
         foreach ($list as $letter => $items) {

--
Gitblit v1.10.0