Component

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

Component helper

View source

Public Methods

MethodDescription
createComponent()Instantiates and populates a component, and ensures that it is an instance of a given interface.
mergeSettings()Extracts settings from a given component config, and returns a new config array wiith the settings merged in.

createComponent()

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

View source

Arguments

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

Returns

craft\base\ComponentInterface – The component

Throws

Signature

public static craft\base\ComponentInterface createComponent ( $config, \craft\helpers\string $instanceOf = null )

mergeSettings()

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

View source

Arguments

Returns

array

Signature

public static array mergeSettings ( array $config )