Jake Vanderwerf
2026-03-08 c19264ac916707096fe294d996a1b7fb85206b34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace JVBase\managers\SEO\render\Traits\_Properties;
 
use JVBase\managers\SEO\render\Thing\Thing;
use JVBase\registrar\config\seo\Resolver;
 
if (!defined('ABSPATH')) {
    exit;
}
trait aboutTrait {
    /**
     * @var Thing The subject matter of an object.
     * Inverse property: subjectOf
     */
    protected Thing $about;
 
    public function getAbout():?Thing
    {
        return $this->about??null;
    }
    public function setAbout(Thing|array $about):void
    {
        if (is_array($about)) {
            if (!array_key_exists('type', $about)) {
                error_log('[aboutTrait] Needs to have a type key'.print_r($about, true));
                return;
            }
            if (!class_exists($about['type'])) {
                error_log('[aboutTrait] Class not found for: '.print_r($about['type'], true));
                return;
            }
            $class = new $about['type']();
            $className = $about['type'];
            unset($about['type']);
            foreach ($about as $key => $value) {
                $method = 'set'.ucfirst($key);
                if (method_exists($class, $method)) {
                    if (is_string($value) && str_contains($value, '{{')) {
                        $value = Resolver::resolveForSchema($key, $value, $class);
                    }
                    error_log('Setting '.$key.' to '.print_r($value, true));
                    $class->$method($value);
                } else {
                    error_log('[aboutTrait] Invalid method: '.$method.', for class: '.$className);
                }
            }
            $about = $class;
        }
        $this->about = $about;
    }
}