PageRenderTime 36ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/framework/caching/dependencies/CExpressionDependency.php

http://github.com/yiisoft/yii
PHP | 55 lines | 13 code | 3 blank | 39 comment | 0 complexity | 17543157380aa8ed401836ee7908b890 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * CExpressionDependency class file.
  4. *
  5. * @author Qiang Xue <qiang.xue@gmail.com>
  6. * @link http://www.yiiframework.com/
  7. * @copyright 2008-2013 Yii Software LLC
  8. * @license http://www.yiiframework.com/license/
  9. */
  10. /**
  11. * CExpressionDependency represents a dependency based on the result of a PHP expression.
  12. *
  13. * CExpressionDependency performs dependency checking based on the
  14. * result of a PHP {@link expression}.
  15. * The dependency is reported as unchanged if and only if the result is
  16. * the same as the one evaluated when storing the data to cache.
  17. *
  18. * @author Qiang Xue <qiang.xue@gmail.com>
  19. * @package system.caching.dependencies
  20. * @since 1.0
  21. */
  22. class CExpressionDependency extends CCacheDependency
  23. {
  24. /**
  25. * @var string the PHP expression whose result is used to determine the dependency.
  26. * The expression can also be a valid serializable PHP callback.
  27. * It will be passed with a parameter which is the dependency object itself.
  28. *
  29. * The PHP expression will be evaluated using {@link evaluateExpression}.
  30. *
  31. * A PHP expression can be any PHP code that has a value. To learn more about what an expression is,
  32. * please refer to the {@link http://www.php.net/manual/en/language.expressions.php php manual}.
  33. */
  34. public $expression;
  35. /**
  36. * Constructor.
  37. * @param string $expression the PHP expression whose result is used to determine the dependency.
  38. */
  39. public function __construct($expression='true')
  40. {
  41. $this->expression=$expression;
  42. }
  43. /**
  44. * Generates the data needed to determine if dependency has been changed.
  45. * This method returns the result of the PHP expression.
  46. * @return mixed the data needed to determine if dependency has been changed.
  47. */
  48. protected function generateDependentData()
  49. {
  50. return $this->evaluateExpression($this->expression);
  51. }
  52. }