/** * Construct a Field by parsing yaml configuration. * * @param array $yaml * Yaml in a standard format as found in contentTypes.yml. * * @return Field * A fully populated Field object. */ public static function parseYaml($yaml) { $field = new Field(); // If we got here, we're not dealing with a global field, so process it normally. if (isset($yaml['machineName'])) { $field->setMachine($yaml['machineName']); } if (isset($yaml['label'])) { $field->setLabel($yaml['label']); } if (isset($yaml['type'])) { $field->setType($yaml['type']); // Only set a widget if one was defined because some fields don't // have anything visible to the user on the edit form. if (isset($yaml['widget'])) { $field->setWidget(Widget::create($yaml, $field)); } } if (isset($yaml['selector']) && $field->getWidget()) { $field->getWidget()->setSelector($yaml['selector']); } if (isset($yaml['required']) && $yaml['required'] != 'false') { $field->setRequired(true); } $preSteps = array(); if (isset($yaml['pre'])) { $preSteps[] = array('click', array($yaml['pre'])); } if (isset($yaml['preSteps'])) { $preSteps = array_merge($preSteps, $yaml['preSteps']); } $field->setPreSteps($preSteps); if (isset($yaml['postSteps'])) { $field->setPostSteps($yaml['postSteps']); } if (isset($yaml['skipRoles']) && is_array($yaml['skipRoles'])) { $field->setSkippedRoles($yaml['skipRoles']); } if (isset($yaml['testData'])) { $field->setTestData($yaml['testData']); } // Only set the widgetNameVisible property to false if the YAML value is // set and also it's specifically set to false. if (isset($yaml['widgetNameVisible']) && $yaml['widgetNameVisible'] === false) { $field->setWidgetNameVisible(false); } else { $field->setWidgetNameVisible(true); } return $field; }
/** * Construct a Field by parsing yaml configuration. * * @param array $yaml * Yaml in a standard format as found in contentTypes.yml. * * @return Field * A fully populated Field object. */ public static function parseYaml($yaml) { $field = new Field(); // If we got here, we're not dealing with a global field, so process it normally. if (isset($yaml['machineName'])) { $field->setMachine($yaml['machineName']); } if (isset($yaml['label'])) { $field->setLabel($yaml['label']); } if (isset($yaml['type'])) { $field->setType($yaml['type']); $field->setWidget(Widget::create($yaml, $field)); } if (isset($yaml['selector'])) { $field->getWidget()->setSelector($yaml['selector']); } if (isset($yaml['required']) && $yaml['required'] !== false) { $field->setRequired(true); } $preSteps = array(); if (isset($yaml['pre'])) { $preSteps[] = array('click', array($yaml['pre'])); } if (isset($yaml['preSteps'])) { $preSteps = array_merge($preSteps, $yaml['preSteps']); } $field->setPreSteps($preSteps); if (isset($yaml['postSteps'])) { $field->setPostSteps($yaml['postSteps']); } if (isset($yaml['skipRoles']) && is_array($yaml['skipRoles'])) { $field->setSkippedRoles($yaml['skipRoles']); } if (isset($yaml['testData'])) { $field->setTestData($yaml['testData']); } return $field; }