<?php
|
namespace JVBase\managers\SEO\render\Traits\_Properties;
|
|
use JVBase\base\SchemaHelper;
|
use JVBase\managers\SEO\render\Thing\Intangible\ContactPoint\PostalAddress;
|
|
if (!defined('ABSPATH')) {
|
exit;
|
}
|
trait addressTrait {
|
/**
|
* @var PostalAddress|string Physical address of the item.
|
*/
|
protected PostalAddress|string $address;
|
|
public function getAddress():PostalAddress|string|null
|
{
|
return $this->address??null;
|
}
|
public function setAddress(PostalAddress|array|string $address):void
|
{
|
if (is_array($address)){
|
if (!array_key_exists('type', $address)) {
|
$address['type'] = 'JVBase\managers\SEO\render\Thing\Intangible\ContactPoint\PostalAddress';
|
}
|
$address = SchemaHelper::classFromConfig($address);
|
}
|
$this->address = $address;
|
}
|
public function getAddressFieldConfig():array
|
{
|
return [
|
'type' => 'group',
|
'label' => 'Address',
|
'wrap' => 'details',
|
'fields' => [
|
'streetAddress' => [
|
'type' => 'text',
|
'label'=> 'Street Address',
|
'hint' => 'The street address. For example, "6551 111 St NW"'
|
],
|
'extendedAddress' => [
|
'type' => 'text',
|
'label'=> 'Extended Address',
|
'hint' => 'An address extension such as an apartment number, C/O or alternative name.'
|
],
|
'postOfficeBoxNumber' => [
|
'type' => 'text',
|
'label' => 'PO Box Number',
|
],
|
'addressLocality' => [
|
'type' => 'text',
|
'label' => 'Address Locality',
|
'hint' => 'The locality in which the street address is, and which is in the region. For example, "Edmonton".'
|
],
|
'addressRegion' => [
|
'type' => 'text',
|
'label' => 'Address Region (Province)',
|
],
|
'postalCode' => [
|
'type' => 'text',
|
'label' => 'Postal Code',
|
'hint' => 'The postal code. For example, T6H 4R5.'
|
],
|
'addressCountry' => [
|
'type' => 'text',
|
'label' => 'Country',
|
'hint' => 'The address country. For example, "CA".',
|
'default' => 'CA'
|
]
|
]
|
];
|
}
|
}
|