From 772462eeca3002a1d52508aeba485aab2b4742ad Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 03 Mar 2026 19:06:19 +0000
Subject: [PATCH] =MAJOR OVERHAUL. Likely should have made a new branch ages ago. Key changes: Registrar.php is the base for custom post types, taxonomies, and user roles. Replaces JVB_CONTENT, JVB_TAXONOMY, and JVB_USER constants, eliminates most of Features.php (except for JVB_SITE, JVB_MEMBERSHIP), and has built in sanitizing and validation via sub-classes. Also started a major overhaul of the Schema output. Created a shit ton of property traits and classes to help sanitize and ensure proper data for different schema types. Still a bunch to do, but better to be starting committing changes here on this other branch.
---
inc/rest/routes/ContentTermsRoutes.php | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/inc/rest/routes/ContentTermsRoutes.php b/inc/rest/routes/ContentTermsRoutes.php
index eee6b6b..d28cb60 100644
--- a/inc/rest/routes/ContentTermsRoutes.php
+++ b/inc/rest/routes/ContentTermsRoutes.php
@@ -3,6 +3,7 @@
use JVBase\managers\queue\executors\ContentTermExecutor;
use JVBase\managers\queue\TypeConfig;
+use JVBase\registrar\Registrar;
use JVBase\rest\Rest;
use JVBase\rest\Route;
use JVBase\rest\PermissionHandler;
@@ -31,7 +32,7 @@
class ContentTermsRoutes extends Rest
{
protected string $taxonomy;
- protected array $config;
+ protected Registrar $registrar;
protected ?CustomTable $historyTable = null;
protected ?CustomTable $requestsTable = null;
@@ -39,8 +40,8 @@
{
$this->taxonomy = jvbNoBase($taxonomy);
- if ($taxonomy && isset(JVB_TAXONOMY[$this->taxonomy])) {
- $this->config = JVB_TAXONOMY[$this->taxonomy];
+ if ($taxonomy !== '' && Registrar::getInstance($this->taxonomy)) {
+ $this->registrar = Registrar::getInstance($this->taxonomy);
$this->cacheName = $this->taxonomy;
parent::__construct();
$this->setupTables();
@@ -54,14 +55,15 @@
{
$registry = JVB()->queue()->registry();
$executor = new ContentTermExecutor();
- $taxonomies = Features::getTypesWithFeature('is_content', 'taxonomy');
+ $taxonomies = Registrar::getFeatured('is_content', 'term');
foreach($taxonomies as $taxonomy) {
$registry->register("{$taxonomy}_update", new TypeConfig(
executor: $executor,
));
- if (Features::forTaxonomy($taxonomy)->has('track_changes')) {
+ $registrar = Registrar::getInstance($taxonomy);
+ if ($registrar && $registrar->hasFeature('track_changes')) {
$registry->register("{$taxonomy}_member_add", new TypeConfig(
executor: $executor
));
@@ -76,9 +78,9 @@
protected function setupTables(): void
{
- $content = $this->config['for_content'] ?? [];
+ $content = $this->registrar->registrar->for;
- if (Features::forTaxonomy($this->taxonomy)->has('track_changes') && !empty($content)) {
+ if ($this->registrar->hasFeature('track_changes') && !empty($content)) {
foreach ($content as $contentType) {
$tableName = "history_{$contentType}_{$this->taxonomy}";
$this->historyTable = CustomTable::for($tableName);
@@ -86,7 +88,7 @@
}
}
- if (Features::forTaxonomy($this->taxonomy)->has('verify_entry') && !empty($content)) {
+ if ($this->registrar->hasFeature('verify_entry') && !empty($content)) {
foreach ($content as $contentType) {
$tableName = "{$contentType}_{$this->taxonomy}_requests";
$this->requestsTable = CustomTable::for($tableName);
@@ -104,7 +106,7 @@
public function registerRoutes(): void
{
- if (!Features::forTaxonomy($this->taxonomy)->has('is_content')) {
+ if (!$this->registrar->hasFeature('is_content')) {
return;
}
@@ -122,7 +124,7 @@
->register();
// Member management (if track_changes enabled)
- if (Features::forTaxonomy($this->taxonomy)->has('track_changes')) {
+ if ($this->registrar->hasFeature('track_changes')) {
Route::for("{$base}/:term_id/members")
->get([$this, 'getMembers'])
->args([
@@ -146,7 +148,7 @@
}
// Membership requests (if verify_entry enabled)
- if (Features::forTaxonomy($this->taxonomy)->has('verify_entry')) {
+ if ($this->registrar->hasFeature('verify_entry')) {
Route::for("{$base}/:term_id/requests")
->get([$this, 'getRequests'])
->args([
@@ -174,7 +176,7 @@
}
// Ownership/management (if is_ownable enabled)
- if (Features::forTaxonomy($this->taxonomy)->has('is_ownable')) {
+ if ($this->registrar->hasFeature('is_ownable')) {
Route::for("{$base}/:term_id/permissions")
->post([$this, 'updatePermissions'])
->args([
--
Gitblit v1.10.0