Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

JsExpression.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\web;
  8. use yii\base\Object;
  9. /**
  10. * JsExpression marks a string as a JavaScript expression.
  11. *
  12. * When using [[\yii\helpers\Json::encode()]] or [[\yii\helpers\Json::htmlEncode()]] to encode a value, JsonExpression objects
  13. * will be specially handled and encoded as a JavaScript expression instead of a string.
  14. *
  15. * @author Qiang Xue <qiang.xue@gmail.com>
  16. * @since 2.0
  17. */
  18. class JsExpression extends Object
  19. {
  20. /**
  21. * @var string the JavaScript expression represented by this object
  22. */
  23. public $expression;
  24. /**
  25. * Constructor.
  26. * @param string $expression the JavaScript expression represented by this object
  27. * @param array $config additional configurations for this object
  28. */
  29. public function __construct($expression, $config = [])
  30. {
  31. $this->expression = $expression;
  32. parent::__construct($config);
  33. }
  34. /**
  35. * The PHP magic function converting an object into a string.
  36. * @return string the JavaScript expression.
  37. */
  38. public function __toString()
  39. {
  40. return $this->expression;
  41. }
  42. }