| | |
| | | namespace JVBase\managers\SEO\render\Traits\_Properties; |
| | | |
| | | use JVBase\managers\SEO\render\Thing\Intangible\StructuredValue\LocationFeatureSpecification; |
| | | use JVBase\managers\SEO\render\Thing\Intangible\StructuredValue\PropertyValue; |
| | | use JVBase\managers\SEO\render\Traits\_Helpers\arrayHelper; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Fields; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | $this->amenityFeature = $amenityFeature; |
| | | } |
| | | |
| | | public function getAmenityFeatureFieldConfig():array |
| | | public function setAmenityFeatureField(Fields $fields):void |
| | | { |
| | | return [ |
| | | 'type' => 'repeater', |
| | | 'label' => 'Amenity Feature', |
| | | 'hint' => 'An amenity feature (e.g. a characteristic or service) of the Accommodation. This generic property does not make a statement about whether the feature is included in an offer for the main accommodation or available at extra costs.', |
| | | 'fields' => [ |
| | | |
| | | $fields->addField('amenityFeature', [ |
| | | 'type' => 'set', |
| | | 'label' => __('Amenities', 'jvb'), |
| | | 'options' => [ |
| | | 'Wheelchair Accessible' => 'Wheelchair Accessible', |
| | | 'Free Parking' => 'Free Parking', |
| | | 'Private Rooms' => 'Private Rooms', |
| | | 'Air Conditioning' => 'Air Conditioning', |
| | | 'WiFi' => 'WiFi', |
| | | 'Gender Neutral Restroom' => 'Gender Neutral Restroom', |
| | | 'LGBTQ+ Friendly' => 'LGBTQ+ Friendly', |
| | | 'Sterilization Room' => 'Sterilization Room', |
| | | 'Refreshments Available' => 'Refreshments Available', |
| | | 'Street Level Access' => 'Street Level Access', |
| | | 'Single Use Needles' => 'Single Use Needles', |
| | | 'Consultation Room' => 'Consultation Room', |
| | | 'Aftercare Products Available' => 'Aftercare Products Available', |
| | | 'Walk-Ins Welcome' => 'Walk-Ins Welcome', |
| | | ] |
| | | ]); |
| | | } |
| | | |
| | | public function formatAmenityFeatureField(Meta $meta):void |
| | | { |
| | | $amenities = $meta->get('amenityFeature'); |
| | | |
| | | $properties = [ |
| | | 'Walk-Ins Welcome', |
| | | 'LGBTQ+ Friendly', |
| | | ]; |
| | | |
| | | if (!empty($amenities)) { |
| | | $out = []; |
| | | $prop = []; |
| | | foreach ($amenities as $amenity) { |
| | | if (in_array($amenity, $properties)) { |
| | | $pr = new PropertyValue(); |
| | | $pr->setName($amenity); |
| | | $pr->setValue(true); |
| | | $prop[] = $pr; |
| | | } else { |
| | | $am = new LocationFeatureSpecification(); |
| | | $am->setName($amenity); |
| | | $am->setValue(true); |
| | | $out[] = $am; |
| | | } |
| | | } |
| | | if (!empty($out)) { |
| | | $this->setAmenityFeature($out); |
| | | } |
| | | if (!empty($prop)) { |
| | | $this->setAdditionalProperty($prop); |
| | | } |
| | | } |
| | | } |
| | | } |