Component

Type
Class
Namespace
craft\helpers
Inherits
craft\helpers\Component
Since
3.0.0

Component helper

View source (opens new window)

# Public Methods

Method Description
cleanseConfig() Cleanses a component config of any on X or as X keys.
createComponent() Instantiates and populates a component, and ensures that it is an instance of a given interface.
iconSvg() Returns an SVG icon’s contents.
mergeSettings() Extracts settings from a given component config, and returns a new config array with the settings merged in.
validateComponentClass() Returns whether a component class exists, is an instance of a given interface, and doesn't belong to a disabled plugin.

# cleanseConfig()

Since
3.9.4

Cleanses a component config of any on X or as X keys.

View source (opens new window)

Arguments

Returns

array (opens new window)

# createComponent()

Instantiates and populates a component, and ensures that it is an instance of a given interface.

View source (opens new window)

Arguments

  • $config (mixed) – The component’s class name, or its config, with a type value and optionally a settings value.
  • $instanceOf (string (opens new window), null (opens new window)) – The class or interface that the component must be an instance of.

Returns

craft\base\ComponentInterface – The component

Throws

# iconSvg()

Since
3.5.0

Returns an SVG icon’s contents.

View source (opens new window)

Arguments

Returns

string (opens new window)

# mergeSettings()

Extracts settings from a given component config, and returns a new config array with the settings merged in.

View source (opens new window)

Arguments

Returns

array (opens new window)

# validateComponentClass()

Since
3.2.0

Returns whether a component class exists, is an instance of a given interface, and doesn't belong to a disabled plugin.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Throws