Documentation ¶
Overview ¶
Package deprecated source provides a slice type for handling config sources to be used in config/models.
In Mage world this is called ToOptionArray() or ToOptionHash().
Index ¶
- Constants
- Variables
- type Bools
- type F64s
- type Ints
- type Optioner
- type Pair
- type Slice
- func (s Slice) ContainsLabel(l string) bool
- func (s Slice) ContainsValBool(k bool) bool
- func (s Slice) ContainsValFloat64(k float64) bool
- func (s Slice) ContainsValInt(k int) bool
- func (s Slice) ContainsValString(k string) bool
- func (s Slice) IndexLabel(l string) int
- func (s Slice) IndexValBool(k bool) int
- func (s Slice) IndexValFloat64(k float64) int
- func (s Slice) IndexValInt(k int) int
- func (s Slice) IndexValString(k string) int
- func (s Slice) Len() int
- func (s *Slice) Merge(sl Slice) Slice
- func (s Slice) SortByBool(direction int) Slice
- func (s Slice) SortByFloat64(direction int) Slice
- func (s Slice) SortByInt(direction int) Slice
- func (s Slice) SortByLabel(direction int) Slice
- func (s Slice) SortByValue(direction int) Slice
- func (s Slice) String() string
- func (s Slice) Swap(i, j int)
- func (s Slice) ToJSON() (string, error)
- func (s *Slice) Unique() Slice
Constants ¶
const ( NotNullString uint8 = iota + 1 NotNullInt NotNullFloat64 NotNullBool )
NotNull* are specifying which type has a non null value
Variables ¶
var EnableDisable = NewByBool(Bools{ {false, "Disable"}, {true, "Enable"}, })
EnableDisable defines an immutable slice with enable and disable options.
var Protocol = MustNewByString(
"", "",
"http", "HTTP (unsecure)",
"https", "HTTP (TLS)",
)
Protocol defines an immutable slice with available HTTP protocols
var YesNo = NewByBool(Bools{ {false, "No"}, {true, "Yes"}, })
YesNo defines an immutable slice with yes and no options.
Functions ¶
This section is empty.
Types ¶
type Optioner ¶
type Optioner interface {
Options() Slice
}
Optioner defines how to retrieve all Options values. Mostly used for frontend output. @see site/lib/internal/Magento/Framework/Data/OptionSourceInterface.php
type Pair ¶
type Pair struct { // NotNull defines which type is not null NotNull uint8 String string `json:"-"` Int int `json:"-"` Float64 float64 `json:"-"` Bool bool `json:"-"` // contains filtered or unexported fields }
Pair contains a different typed values and a label for printing in a browser. Especially useful for JS API and in total for value validation.
func (Pair) MarshalJSON ¶
MarshalJSON encodes a pair into JSON
func (*Pair) UnmarshalJSON ¶
UnmarshalJSON decodes a pair from JSON
type Slice ¶
type Slice []Pair
Slice type is returned by the SourceModel.Options() interface
func MustNewByString ¶
MustNewByString same as NewByString but panics on error.
func NewByFloat64 ¶
NewByFloat64 creates a new slice with float64 values
func NewByIntValue ¶
NewByIntValue all passed arguments are values.
func NewByString ¶
NewByString creates a new ValueLabelSlice (VLS) from key,value list. It panics when arguments are imbalanced. Example:
mySlice := NewValueLabelSlice("http", "HTTP (unsecure)", "https", "HTTPS (TLS)")
Error behaviour: NotValid.
func NewByStringValue ¶
NewByStringValue all passed arguments are values.
func (Slice) ContainsLabel ¶
ContainsLabel checks if k has an entry as a label.
func (Slice) ContainsValBool ¶
ContainsValBool checks if value k exists.
func (Slice) ContainsValFloat64 ¶
ContainsValFloat64 checks if value k exists.
func (Slice) ContainsValInt ¶
ContainsValInt checks if value k exists.
func (Slice) ContainsValString ¶
ContainsValString checks if value k exists.
func (Slice) IndexLabel ¶
IndexLabel checks if label l exists and returns its first position. Returns -1 when the label was not found.
func (Slice) IndexValBool ¶
IndexValBool checks if value k exists and returns its position. Returns -1 when the value was not found.
func (Slice) IndexValFloat64 ¶
IndexValFloat64 checks if value k exists and returns its position. Returns -1 when the value was not found.
func (Slice) IndexValInt ¶
IndexValInt checks if value k exists and returns its position. Returns -1 when the value was not found.
func (Slice) IndexValString ¶
IndexValString checks if value k exists and returns its position. Returns -1 when the value was not found.
func (*Slice) Merge ¶
Merge integrates the argument Slice into the receiver slice and overwrites the existing values of the receiver slice.
func (Slice) SortByBool ¶
SortByBool sorts by field Bool in asc = 0 or desc != 0 direction
func (Slice) SortByFloat64 ¶
SortByFloat64 sorts by field Float64 in asc = 0 or desc != 0 direction
func (Slice) SortByLabel ¶
SortByLabel sorts by label in asc = 0 or desc != 0 direction
func (Slice) SortByValue ¶
SortByValue sorts by value in asc = 0 or desc != 0 direction. The underlying value will be converted to a string. You might expect strange results when sorting integers or other non-strings.