public static function valuesToUnderscore($array)
 {
     $output = [];
     foreach ($array as $value) {
         $output[] = StringHelper::camelCaseToUnderscore($value);
     }
     return $output;
 }
 public function __get($name)
 {
     try {
         return parent::__get($name);
     } catch (CException $e) {
         $method_name = StringHelper::underscoreToCamelcase($name);
         if (method_exists($this, 'get' . ucfirst($method_name))) {
             return $this->{$method_name};
         } else {
             $attr = StringHelper::camelCaseToUnderscore($name);
             if (mb_substr($attr, 0, 4) == 'get_') {
                 $attr = mb_substr($attr, 4);
             }
             $attr = get_class($this) . '.' . $attr;
             throw new CException('Не определено свойство ' . $attr);
         }
     }
 }
Beispiel #3
0
 /**
  * Обертка для Yii::t, выполняет перевод по словарям текущего модуля.
  * Так же перевод осуществляется по словорям с префиксом {modelId},
  * где modelId - приведенная к нижнему регистру база имени контроллера
  *
  * Например: для контроллера ProductInfoAdminController, находящегося в модуле ProductsModule
  * перевод будет осуществляться по словарю ProductsModule.product_info_{первый параметр метода}
  *
  * @param string $dictionary словарь
  * @param string $alias      фраза для перевода
  * @param array  $params
  * @param string $language
  *
  * @return string переводa
  */
 public function t($dictionary, $alias, $params = array(), $source = null, $language = null)
 {
     $file_prefix = StringHelper::camelCaseToUnderscore($this->getModelClass());
     return Yii::t(get_class($this->module) . '.' . $file_prefix . '_' . $dictionary, $alias, $params, $source, $language);
 }