Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
f043aa5e
Commit
f043aa5e
authored
Jul 03, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Formatter::format().
parent
33c36f2a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
Formatter.php
framework/yii/base/Formatter.php
+20
-0
No files found.
framework/yii/base/Formatter.php
View file @
f043aa5e
...
@@ -71,6 +71,26 @@ class Formatter extends Component
...
@@ -71,6 +71,26 @@ class Formatter extends Component
}
}
/**
/**
* Formats the value based on the give type.
* This method will call one of the "as" methods available in this class to do the formatting.
* For type "xyz", the method "asXyz" will be used. For example, if the type is "html",
* then [[asHtml()]] will be used. Type names are case insensitive.
* @param mixed $value the value to be formatted
* @param string $type the type of the value, e.g., "html", "text".
* @return string the formatting result
* @throws InvalidParamException if the type is not supported by this class.
*/
public
function
format
(
$value
,
$type
)
{
$method
=
'as'
.
$type
;
if
(
method_exists
(
$this
,
$method
))
{
return
$this
->
$method
(
$value
);
}
else
{
throw
new
InvalidParamException
(
"Unknown type:
$type
"
);
}
}
/**
* Formats the value as is without any formatting.
* Formats the value as is without any formatting.
* This method simply returns back the parameter without any format.
* This method simply returns back the parameter without any format.
* @param mixed $value the value to be formatted
* @param mixed $value the value to be formatted
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment