Contao\Widget::__get PHP Method

__get() public method

Return an object property
public __get ( string $strKey ) : string
$strKey string The property name
return string The property value
    public function __get($strKey)
    {
        switch ($strKey) {
            case 'id':
                return $this->strId;
                break;
            case 'name':
                return $this->strName;
                break;
            case 'label':
                return $this->strLabel;
                break;
            case 'value':
                // Encrypt the value
                if ($this->arrConfiguration['encrypt']) {
                    return \Encryption::encrypt($this->varValue);
                } elseif ($this->varValue == '') {
                    return $this->getEmptyStringOrNull();
                }
                return $this->varValue;
                break;
            case 'class':
                return $this->strClass;
                break;
            case 'prefix':
                return $this->strPrefix;
                break;
            case 'template':
                return $this->strTemplate;
                break;
            case 'wizard':
                return $this->strWizard;
                break;
            case 'required':
                return $this->arrConfiguration[$strKey];
                break;
            case 'forAttribute':
                return $this->blnForAttribute;
                break;
            case 'dataContainer':
                return $this->objDca;
                break;
            case 'activeRecord':
                return $this->objDca->activeRecord;
                break;
            default:
                if (isset($this->arrAttributes[$strKey])) {
                    return $this->arrAttributes[$strKey];
                } elseif (isset($this->arrConfiguration[$strKey])) {
                    return $this->arrConfiguration[$strKey];
                }
                break;
        }
        return parent::__get($strKey);
    }

Usage Example

Esempio n. 1
0
 /**
  * Return a parameter
  *
  * @param string $strKey The parameter key
  *
  * @return mixed The parameter value
  */
 public function __get($strKey)
 {
     switch ($strKey) {
         case 'name':
             return $this->strCaptchaKey;
             break;
         case 'question':
             return $this->strQuestion;
             break;
         default:
             return parent::__get($strKey);
             break;
     }
 }