Jake Vanderwerf
2026-08-25 3d25ad7de4fdbb3eba2cde2a62422e6be5d79a0a
inc/managers/DirectoryManager.php
@@ -5,6 +5,7 @@
   exit;
}
use JVBase\Instance;
use JVBase\registrar\Registrar;
use JVBase\base\Site;
use WP_Block;
@@ -12,6 +13,7 @@
class DirectoryManager
{
   use Instance;
    protected array $directories;
    protected array $directoryPageIDs;
   protected array $directoryList;
@@ -20,7 +22,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,9 +30,6 @@
        }
      $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();
@@ -39,6 +38,14 @@
      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, 'flushCache']);
      add_action('edit_terms', [$this, 'flushCache']);
    }
   public function flushPostCache(int $postID):void
   {
      //TODO: We can probably use a bit more finesse here.
      $this->cache->flush();
    }
    public function registerDirectories():void