Prado\Web\UI\TTheme::applySkin PHP 메소드

applySkin() 공개 메소드

The control's class name and SkinID value will be used to identify which skin to be applied. If the control's SkinID is empty, the default skin will be applied.
public applySkin ( $control ) : boolean
리턴 boolean if a skin is successfully applied
    public function applySkin($control)
    {
        $type = get_class($control);
        if (($id = $control->getSkinID()) === '') {
            $id = 0;
        }
        if (isset($this->_skins[$type][$id])) {
            foreach ($this->_skins[$type][$id] as $name => $value) {
                Prado::trace("Applying skin {$name} to {$type}", 'Prado\\Web\\UI\\TThemeManager');
                if (is_array($value)) {
                    switch ($value[0]) {
                        case TTemplate::CONFIG_EXPRESSION:
                            $value = $this->evaluateExpression($value[1]);
                            break;
                        case TTemplate::CONFIG_ASSET:
                            $value = $this->_themeUrl . '/' . ltrim($value[1], '/');
                            break;
                        case TTemplate::CONFIG_DATABIND:
                            $control->bindProperty($name, $value[1]);
                            break;
                        case TTemplate::CONFIG_PARAMETER:
                            $control->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1]));
                            break;
                        case TTemplate::CONFIG_TEMPLATE:
                            $control->setSubProperty($name, $value[1]);
                            break;
                        case TTemplate::CONFIG_LOCALIZATION:
                            $control->setSubProperty($name, Prado::localize($value[1]));
                            break;
                        default:
                            throw new TConfigurationException('theme_tag_unexpected', $name, $value[0]);
                            break;
                    }
                }
                if (!is_array($value)) {
                    if (strpos($name, '.') === false) {
                        if ($control->hasProperty($name)) {
                            if ($control->canSetProperty($name)) {
                                $setter = 'set' . $name;
                                $control->{$setter}($value);
                            } else {
                                throw new TConfigurationException('theme_property_readonly', $type, $name);
                            }
                        } else {
                            throw new TConfigurationException('theme_property_undefined', $type, $name);
                        }
                    } else {
                        // complex property
                        $control->setSubProperty($name, $value);
                    }
                }
            }
            return true;
        } else {
            return false;
        }
    }