1<?php 2 3 4namespace ComboStrap; 5 6/** 7 * Class MetadataFormStore 8 * @package ComboStrap 9 * Represents a data array of a post from an HTML form 10 * ie formData 11 */ 12class MetadataFormDataStore extends MetadataSingleArrayStore 13{ 14 15 16 public static function getOrCreateFromResource(ResourceCombo $resourceCombo, array $formData = []): MetadataStore 17 { 18 return new MetadataFormDataStore($resourceCombo, $formData); 19 } 20 21 22 public function get(Metadata $metadata, $default = null) 23 { 24 $this->checkResource($metadata->getResource()); 25 /** 26 * In a form, the name is send, not the {@link Metadata::getPersistentName()} 27 */ 28 $value = $this->data[$metadata::getName()]; 29 if ($value !== null) { 30 return $value; 31 } 32 return $default; 33 } 34 35 36} 37