示例#1
0
 /**
  * Get a parameter by key
  * @param $key Parameter key eg: editor.width
  * @param $fallback Fallback value
  * @param $default Default value
  */
 public function getParam($key, $fallback = '', $default = '')
 {
     // get plugin name
     $name = $this->getName();
     // get all keys
     $keys = explode('.', $key);
     // root key set
     if ($keys[0] === 'editor' || $keys[0] === $name) {
         return parent::getParam($key, $fallback, $default);
         // no root key set, treat as shared param
     } else {
         // get all params
         $params = parent::getParams();
         // check plugin param and fallback to editor param
         $param = $params->get($name . '.' . $key, $params->get('editor.' . $key, $fallback));
         if (is_string($param)) {
             $param = parent::cleanParam($param);
         }
         if (is_numeric($default)) {
             $default = intval($default);
         }
         if (is_numeric($param)) {
             $param = intval($param);
         }
         return $param === $default ? '' : $param;
     }
 }