Overview

Namespaces

  • None
  • Wei
    • Validator

Classes

  • Wei\Validator\All
  • Wei\Validator\AllOf
  • Wei\Validator\Alnum
  • Wei\Validator\Alpha
  • Wei\Validator\BaseValidator
  • Wei\Validator\Between
  • Wei\Validator\Blank
  • Wei\Validator\Callback
  • Wei\Validator\CharLength
  • Wei\Validator\Chinese
  • Wei\Validator\Color
  • Wei\Validator\Contains
  • Wei\Validator\CreditCard
  • Wei\Validator\Date
  • Wei\Validator\DateTime
  • Wei\Validator\Decimal
  • Wei\Validator\Digit
  • Wei\Validator\Dir
  • Wei\Validator\DivisibleBy
  • Wei\Validator\DoubleByte
  • Wei\Validator\Email
  • Wei\Validator\EndsWith
  • Wei\Validator\EqualTo
  • Wei\Validator\Exists
  • Wei\Validator\FieldExists
  • Wei\Validator\File
  • Wei\Validator\GreaterThan
  • Wei\Validator\GreaterThanOrEqual
  • Wei\Validator\IdCardCn
  • Wei\Validator\IdCardHk
  • Wei\Validator\IdCardMo
  • Wei\Validator\IdCardTw
  • Wei\Validator\IdenticalTo
  • Wei\Validator\Image
  • Wei\Validator\In
  • Wei\Validator\Ip
  • Wei\Validator\Length
  • Wei\Validator\LessThan
  • Wei\Validator\LessThanOrEqual
  • Wei\Validator\Lowercase
  • Wei\Validator\Luhn
  • Wei\Validator\MaxLength
  • Wei\Validator\MinLength
  • Wei\Validator\MobileCn
  • Wei\Validator\NaturalNumber
  • Wei\Validator\NoneOf
  • Wei\Validator\Null
  • Wei\Validator\Number
  • Wei\Validator\OneOf
  • Wei\Validator\Password
  • Wei\Validator\Phone
  • Wei\Validator\PhoneCn
  • Wei\Validator\PlateNumberCn
  • Wei\Validator\PositiveInteger
  • Wei\Validator\PostcodeCn
  • Wei\Validator\Present
  • Wei\Validator\QQ
  • Wei\Validator\RecordExists
  • Wei\Validator\Regex
  • Wei\Validator\Required
  • Wei\Validator\SomeOf
  • Wei\Validator\StartsWith
  • Wei\Validator\Time
  • Wei\Validator\Tld
  • Wei\Validator\Type
  • Wei\Validator\Uppercase
  • Wei\Validator\Url
  • Wei\Validator\Uuid
  • Overview
  • Namespace
  • Function
 1: <?php
 2: /**
 3:  * Wei Framework
 4:  *
 5:  * @copyright   Copyright (c) 2008-2015 Twin Huang
 6:  * @license     http://opensource.org/licenses/mit-license.php MIT License
 7:  */
 8: 
 9: namespace Wei;
10: 
11: /**
12:  * A service to manage service container configurations
13:  *
14:  * @author      Twin Huang <twinhuang@qq.com>
15:  */
16: class Config extends Base
17: {
18:     /**
19:      * Convert configuration data to JSON
20:      *
21:      * @param string $name The name of configuration item
22:      * @return string
23:      */
24:     public function toJson($name)
25:     {
26:         return json_encode($this->wei->getConfig($name));
27:     }
28: 
29:     /**
30:      * Convert configuration data to HTML select options
31:      *
32:      * @param string $name The name of configuration item
33:      * @return string
34:      */
35:     public function toOptions($name)
36:     {
37:         $html = '';
38:         foreach ($this->wei->getConfig($name) as $value => $text) {
39:             if (is_array($text)) {
40:                 $html .= '<optgroup label="' . $value . '">';
41:                 foreach ($text as $v => $t) {
42:                     $html .= '<option value="' . $v . '">' . $t . '</option>';
43:                 }
44:                 $html .= '</optgroup>';
45:             } else {
46:                 $html .= '<option value="' . $value . '">' . $text . '</option>';
47:             }
48:         }
49:         return $html;
50:     }
51: 
52:     /**
53:      * Returns the value by the map name and key
54:      *
55:      * @param string $name The name of the map
56:      * @param string $key The key name in the map
57:      * @return mixed
58:      */
59:     public function getMap($name, $key)
60:     {
61:         return $this->wei->getConfig($name . ':' . $key);
62:     }
63: }
64: 
Wei Framework API documentation generated by ApiGen