<?php
|
namespace JVBase\managers\SEO\schemas;
|
|
if (!defined('ABSPATH')) {
|
exit;
|
}
|
|
/**
|
* Value object representing a schema entity to be resolved.
|
*
|
* Like Operation.php holds the data for a queue item,
|
* this holds the data for a schema entity being built.
|
*/
|
final class SchemaDefinition
|
{
|
/** @var string Schema.org type (e.g., 'TattooParlor', 'VisualArtwork') */
|
public string $schemaType = '';
|
|
/** @var string|null JSON-LD @id (e.g., 'https://site.com/#organization') */
|
public ?string $id = null;
|
|
/** @var int|null WordPress object ID (post ID, term ID, user ID) */
|
public ?int $objectId = null;
|
|
/** @var string|null Object type: post, term, user, archive */
|
public ?string $objectType = null;
|
|
/** @var string|null Content type slug from constants (tattoo, artist, shop) */
|
public ?string $contentType = null;
|
|
/** @var array Saved SEO config from ConfigManager */
|
public array $config = [];
|
|
/** @var array Additional context (archive type, parent term, etc.) */
|
public array $context = [];
|
|
/**
|
* Create from the current SchemaOutputManager context
|
*/
|
public static function fromContext(
|
string $schemaType,
|
array $config,
|
?string $id = null,
|
?array $wpContext = null
|
): self {
|
$def = new self();
|
$def->schemaType = $schemaType;
|
$def->config = $config;
|
$def->id = $id;
|
|
if ($wpContext) {
|
$def->objectId = $wpContext['objectId'] ?? null;
|
$def->objectType = $wpContext['objectType'] ?? null;
|
$def->contentType = $wpContext['type'] ?? null;
|
}
|
|
return $def;
|
}
|
}
|