Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CDateTimeParser
  • CFileHelper
  • CFormatter
  • CLocalizedFormatter
  • CMarkdownParser
  • CPasswordHelper
  • CPropertyValue
  • CTimestamp
  • CVarDumper
  • Overview
  • Package
  • Class
  • Tree

Class CPropertyValue

CPropertyValue is a helper class that provides static methods to convert component property values to specific types.

CPropertyValue is commonly used in component setter methods to ensure the new property value is of the specific type. For example, a boolean-typed property setter method would be as follows,

public function setPropertyName($value)
{
    $value=CPropertyValue::ensureBoolean($value);
    // $value is now of boolean type
}
Properties can be of the following types with specific type conversion rules:
  • string: a boolean value will be converted to 'true' or 'false'.
  • boolean: string 'true' (case-insensitive) will be converted to true, string 'false' (case-insensitive) will be converted to false.
  • integer
  • float
  • array: string starting with '(' and ending with ')' will be considered as as an array expression and will be evaluated. Otherwise, an array with the value to be ensured is returned.
  • object
  • enum: enumerable type, represented by an array of strings.
Package: system\utils
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/utils/CPropertyValue.php
Methods summary
public static boolean
# ensureBoolean( mixed $value )

Converts a value to boolean type. Note, string 'true' (case-insensitive) will be converted to true, string 'false' (case-insensitive) will be converted to false. If a string represents a non-zero number, it will be treated as true.

Converts a value to boolean type. Note, string 'true' (case-insensitive) will be converted to true, string 'false' (case-insensitive) will be converted to false. If a string represents a non-zero number, it will be treated as true.

Parameters

$value
mixed
$value the value to be converted.

Returns

boolean
public static string
# ensureString( mixed $value )

Converts a value to string type. Note, a boolean value will be converted to 'true' if it is true and 'false' if it is false.

Converts a value to string type. Note, a boolean value will be converted to 'true' if it is true and 'false' if it is false.

Parameters

$value
mixed
$value the value to be converted.

Returns

string
public static integer
# ensureInteger( mixed $value )

Converts a value to integer type.

Converts a value to integer type.

Parameters

$value
mixed
$value the value to be converted.

Returns

integer
public static float
# ensureFloat( mixed $value )

Converts a value to float type.

Converts a value to float type.

Parameters

$value
mixed
$value the value to be converted.

Returns

float
public static array
# ensureArray( mixed $value )

Converts a value to array type. If the value is a string and it is in the form (a,b,c) then an array consisting of each of the elements will be returned. If the value is a string and it is not in this form then an array consisting of just the string will be returned. If the value is not a string then

Converts a value to array type. If the value is a string and it is in the form (a,b,c) then an array consisting of each of the elements will be returned. If the value is a string and it is not in this form then an array consisting of just the string will be returned. If the value is not a string then

Parameters

$value
mixed
$value the value to be converted.

Returns

array
public static object
# ensureObject( mixed $value )

Converts a value to object type.

Converts a value to object type.

Parameters

$value
mixed
$value the value to be converted.

Returns

object
public static string
# ensureEnum( string $value, string $enumType )

Converts a value to enum type.

Converts a value to enum type.

This method checks if the value is of the specified enumerable type. A value is a valid enumerable value if it is equal to the name of a constant in the specified enumerable type (class). For more details about enumerable, see CEnumerable.

Parameters

$value
string
$value the enumerable value to be checked.
$enumType
string
$enumType the enumerable class name (make sure it is included before calling this function).

Returns

string
the valid enumeration value

Throws

CException
if the value is not a valid enumerable value
API documentation generated by ApiGen 2.8.0