/** * @param string $alias * @param mixed $setting * @return Field|NULL * @throws Exception */ public static function fromJSONAliasSetting($alias, $setting) { $fieldSetting = NULL; if (!isset($setting['resources'])) { // not many-to-one $field = isset($setting['field']) ? $setting['field'] : $alias; $type = isset($setting['type']) ? Type\Variable::typeFromString($setting['type']) : Type\Variable::STRING; if (!isset($type)) { throw new Exception(Exception::Config, "Type '{$setting['type']}' is invalid for alias '{$alias}'"); } $fieldSetting = Settings::field($alias, $field, $type); } return $fieldSetting; }