Craft 3 Class Reference

Class craft\helpers\Component

Inheritance
craft\helpers\Component
Available since version
3.0
Source Code
https://github.com/craftcms/cms/blob/master/src/helpers/Component.php

Component helper

Public Methods
Method Description Defined By
createComponent() Instantiates and populates a component, and ensures that it is an instance of a given interface. craft\helpers\Component
mergeSettings() Extracts settings from a given component config, and returns a new config array wiith the settings merged in. craft\helpers\Component

Method Details

createComponent() public static method #

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

public static craft\base\ComponentInterface createComponent ( $config, \craft\helpers\string $instanceOf null )
$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.
return craft\base\ComponentInterface The component
throws yii\base\InvalidConfigException if $config doesn’t contain a type value, or the type isn’s compatible with|null $instanceOf.
throws craft\errors\MissingComponentException if the class specified by $config doesn’t exist, or belongs to an uninstalled plugin

mergeSettings() public static method #

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

public static array mergeSettings ( array $config )
$config array