You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
12 years ago
|
<?php
|
||
|
/**
|
||
|
* @link http://www.yiiframework.com/
|
||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||
|
* @license http://www.yiiframework.com/license/
|
||
|
*/
|
||
|
|
||
|
namespace yii\helpers;
|
||
|
|
||
|
use yii\base\Object;
|
||
|
|
||
|
/**
|
||
12 years ago
|
* JsExpression marks a string as a JavaScript expression.
|
||
12 years ago
|
* When using [[Json::encode()]] to encode a value, JsonExpression objects
|
||
|
* will be specially handled and encoded as a JavaScript expression instead of a string.
|
||
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||
|
* @since 2.0
|
||
|
*/
|
||
12 years ago
|
class JsExpression extends Object
|
||
12 years ago
|
{
|
||
|
/**
|
||
|
* @var string the JavaScript expression represented by this object
|
||
|
*/
|
||
|
public $expression;
|
||
|
|
||
|
/**
|
||
|
* Constructor.
|
||
|
* @param string $expression the JavaScript expression represented by this object
|
||
|
* @param array $config additional configurations for this object
|
||
|
*/
|
||
|
public function __construct($expression, $config = array())
|
||
|
{
|
||
|
$this->expression = $expression;
|
||
|
parent::__construct($config);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* The PHP magic function converting an object into a string.
|
||
|
* @return string the JavaScript expression.
|
||
|
*/
|
||
|
public function __toString()
|
||
|
{
|
||
|
return $this->expression;
|
||
|
}
|
||
|
}
|