当前位置: 首页>>代码示例>>PHP>>正文


PHP Utilities::formatClassName方法代码示例

本文整理汇总了PHP中Utilities::formatClassName方法的典型用法代码示例。如果您正苦于以下问题:PHP Utilities::formatClassName方法的具体用法?PHP Utilities::formatClassName怎么用?PHP Utilities::formatClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utilities的用法示例。


在下文中一共展示了Utilities::formatClassName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: findController

 /**
  * Find a controller based on the parsed request path
  */
 protected function findController()
 {
     $parts = $this->path;
     $className = '\\Controllers\\';
     array_pop($parts);
     $dir = APPLICATION_PATH . '/controllers/';
     foreach ($parts as $part) {
         if (file_exists($dir . $part . '.php')) {
             $this->controller = $dir . $part . '.php';
             $this->controllerClassName = $className . Utilities::formatClassName($part);
             return;
         }
         if (!is_dir($dir . $part . '/')) {
             break;
         }
         $dir .= $part . '/';
         if (file_exists($dir . 'Index.php')) {
             $this->controller = $dir . 'Index.php';
             $this->controllerClassName = $className . 'Index';
             return;
         }
     }
     if (file_exists($dir . 'Index.php')) {
         $this->controller = $dir . 'Index.php';
         $this->controllerClassName = $className . 'Index';
     }
 }
开发者ID:ArtifexTech,项目名称:life-jacket,代码行数:30,代码来源:Router.php

示例2: __construct

 /**
  * StringsHandler constructor.
  */
 public function __construct()
 {
     $config = Config::getInstance();
     $adapterClass = __NAMESPACE__ . '\\ConfigAdapter\\' . Utilities::formatClassName($config->get('strings_adapter', 'ini'));
     $this->adapter = new $adapterClass('strings');
     $this->loadStrings();
 }
开发者ID:ArtifexTech,项目名称:life-jacket,代码行数:10,代码来源:StringsHandler.php

示例3: getInstance

 /**
  * Get singleton instance
  *
  * @return Cache
  */
 public static function getInstance()
 {
     if (null === static::$instance) {
         $config = Config::getInstance();
         $adapterClass = __NAMESPACE__ . '\\CacheAdapter\\' . Utilities::formatClassName($config->get('cache_adapter', 'file'));
         static::$instance = new static();
         static::$instance->adapter = new $adapterClass();
     }
     return static::$instance;
 }
开发者ID:ArtifexTech,项目名称:life-jacket,代码行数:15,代码来源:Cache.php

示例4: __construct

 /**
  * FormValidator constructor.
  * @param array $post
  * @param View $view
  */
 public function __construct(array $post, View $view)
 {
     $this->view = $view;
     $errors = array();
     $fields = $this->view->getFormFields();
     $formData = array();
     foreach ($fields as $name => $field) {
         // filter values
         $value = !empty($post[$name]) ? trim($post[$name]) : '';
         $formattedName = Utilities::formatClassName($name);
         // validate data
         if (isset($field['required']) && $field['required'] != 'false' && empty($value)) {
             $errors[$name] = $formattedName . ' is a required field.';
         }
         if (!empty($value)) {
             if (isset($field['type']) && $field['type'] == 'email' && !$this->isValidEmail($value)) {
                 $errors[$name] = $formattedName . ' must be a valid email address.';
             }
             if (isset($field['type']) && $field['type'] == 'url' && !preg_match('@^https?://@', $value)) {
                 $errors[$name] = $formattedName . ' must be a valid URL.';
             }
             if (isset($field['maxlength']) && $field['maxlength'] < trim(strlen($value))) {
                 $errors[$name] = $formattedName . ' can not be more than ' . $field['maxlength'] . ' characters.';
             }
             if (isset($field['minlength']) && $field['minlength'] > trim(strlen($value))) {
                 $errors[$name] = $formattedName . ' must be more than ' . $field['minlength'] . ' characters.';
             }
             if (isset($field['type']) && $field['type'] == 'number') {
                 $value = (double) $value;
                 if (isset($field['max']) && $field['max'] < $value) {
                     $errors[$name] = $formattedName . ' must be a number less than ' . $field['max'] . '.';
                 }
                 if (isset($field['min']) && $field['min'] > $value) {
                     $errors[$name] = $formattedName . ' must be a number greater than ' . $field['min'] . '.';
                 }
             }
             if (isset($field['pattern']) && !preg_match('/' . str_replace('/', '\\/', $field['pattern']) . '/', $value)) {
                 $errors[$name] = $formattedName . ' is not in a valid format.';
             }
         }
         $formData[$name] = $value;
     }
     // validate recaptcha
     $config = Config::getInstance();
     if ($config->recaptcha_on && !$this->isValidCaptcha()) {
         $errors['recaptcha'] = 'An incorrect CAPTCHA code was entered.';
     }
     $this->errors = $errors;
     $this->data = $formData;
 }
开发者ID:ArtifexTech,项目名称:life-jacket,代码行数:55,代码来源:FormValidator.php

示例5: renderFields

 /**
  * Render fields for a specific section
  *
  * @param array $items
  * @param array $groups
  * @param string $rowTemplate
  * @param string $fieldGroup
  * @return array
  */
 protected function renderFields(array $items, array $groups, $rowTemplate, $fieldGroup = '', $isSeries = false)
 {
     $rows = array();
     foreach ($items as $key => $value) {
         // detect special suffixes
         $suffix = $fieldGroup == '' ? 'textarea' : 'text';
         $suffixOffset = strpos($key, '/');
         if ($suffixOffset !== false) {
             $suffix = substr($key, $suffixOffset + 1);
         }
         // format values
         $name = $fieldGroup == '' ? sprintf('data[%s][%s]', implode('][', $groups), $key) : "{$fieldGroup}[{$key}]";
         $label = ucwords(preg_replace('/\\/.+/', '', str_replace(array('-', '_'), ' ', $key)));
         if ($isSeries) {
             $name .= '[]';
         }
         // determine helper class to use for rendering form field
         $helperClass = __NAMESPACE__ . '\\TokenHelpers\\' . Utilities::formatClassName($suffix);
         $helper = new $helperClass($value, $name, $label);
         // add field to row
         if (!is_array($value)) {
             $rows[] = str_replace('[[__content]]', $helper->getField(), $rowTemplate);
         } else {
             // iterate through and process tokens each item
             $subFieldGroups = array();
             // restructure array
             $subValues = array();
             foreach ($value as $subStringKey => $subStringValues) {
                 $i = 0;
                 foreach ($subStringValues as $subStringValue) {
                     if (!isset($subValues[$i])) {
                         $subValues[$i] = array();
                     }
                     $subValues[$i][$subStringKey] = $subStringValue;
                     ++$i;
                 }
             }
             // build sub-field groups
             foreach ($subValues as $subValue) {
                 $subFields = $this->renderFields($subValue, array_merge($groups, array($key)), $rowTemplate, $fieldGroup, true);
                 $subFieldGroups[] = $helper->processFields($subFields);
             }
             $rows[] = $helper->processFieldGroup($subFieldGroups);
         }
     }
     return $rows;
 }
开发者ID:ArtifexTech,项目名称:life-jacket,代码行数:56,代码来源:Controller.php

示例6: processTokens

 /**
  * Process tokens found within templates
  *
  * @param string $tokenGroup
  * @param array $strings
  * @param string $html
  * @return string
  */
 protected function processTokens($tokenGroup, $strings, $html)
 {
     // process any global tokens
     if (!empty($strings['_global'])) {
         foreach ($strings['_global'] as $token => $value) {
             $html = str_replace('[[' . $token . ']]', $value, $html);
         }
     }
     // process any action specific tokens
     if (isset($strings[$tokenGroup])) {
         foreach ($strings[$tokenGroup] as $token => $value) {
             // detect special suffixes
             $suffix = 'textarea';
             $suffixOffset = strpos($token, '/');
             if ($suffixOffset !== false) {
                 $suffix = substr($token, $suffixOffset + 1);
             }
             // determine helper class to use for rendering token's string
             $helperClass = __NAMESPACE__ . '\\TokenHelpers\\' . Utilities::formatClassName($suffix);
             $helper = new $helperClass($value, $token);
             // replace token with string in HTML
             if (!is_array($value)) {
                 $html = str_replace('[[' . $token . ']]', $helper->getString(), $html);
             } else {
                 // get html slice within repeater region
                 if (!preg_match('@\\[\\[' . $token . '\\]\\](.*?)\\[\\[/' . $token . '\\]\\]@mis', $html, $match)) {
                     continue;
                 }
                 $htmlSlice = $match[1];
                 // restructure array
                 $subValues = array();
                 foreach ($value as $subStringKey => $subStringValues) {
                     $i = 0;
                     foreach ($subStringValues as $subStringValue) {
                         if (!isset($subValues[$i])) {
                             $subValues[$i] = array();
                         }
                         $subValues[$i][$subStringKey] = $subStringValue;
                         ++$i;
                     }
                 }
                 // iterate through and process tokens each item
                 $output = array();
                 foreach ($subValues as $subStrings) {
                     $output[] = $this->processTokens(0, array($subStrings), $htmlSlice);
                 }
                 // process item results with repeater token helper
                 $htmlSlice = $helper->processRegion($output);
                 // replace original html region slice with new content
                 $html = preg_replace('@\\[\\[' . $token . '\\]\\].*?\\[\\[/' . $token . '\\]\\]@mis', $htmlSlice, $html);
             }
         }
     }
     return $html;
 }
开发者ID:ArtifexTech,项目名称:life-jacket,代码行数:63,代码来源:View.php


注:本文中的Utilities::formatClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。