PageRenderTime 1111ms CodeModel.GetById 34ms RepoModel.GetById 5ms app.codeStats 0ms

/yii/framework/caching/dependencies/CExpressionDependency.php

https://github.com/ashie1287/headfirst
PHP | 53 lines | 13 code | 3 blank | 37 comment | 0 complexity | e8777274853f3d8b775481a78cd4ec11 MD5 | raw file
Possible License(s): BSD-2-Clause, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * CExpressionDependency class file.
  4. *
  5. * @author Qiang Xue <qiang.xue@gmail.com>
  6. * @link http://www.yiiframework.com/
  7. * @copyright Copyright &copy; 2008-2010 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. * @version $Id: CExpressionDependency.php 1678 2010-01-07 21:02:00Z qiang.xue $
  20. * @package system.caching.dependencies
  21. * @since 1.0
  22. */
  23. class CExpressionDependency extends CCacheDependency
  24. {
  25. /**
  26. * @var string the PHP expression whose result is used to determine the dependency.
  27. * Starting from version 1.0.11, the expression can also be a valid PHP callback,
  28. * including class method name (array(ClassName/Object, MethodName)),
  29. * or anonymous function (PHP 5.3.0+). The function/method will be passed with a
  30. * parameter which is the dependency object itself.
  31. */
  32. public $expression;
  33. /**
  34. * Constructor.
  35. * @param string the PHP expression whose result is used to determine the dependency.
  36. */
  37. public function __construct($expression='true')
  38. {
  39. $this->expression=$expression;
  40. }
  41. /**
  42. * Generates the data needed to determine if dependency has been changed.
  43. * This method returns the result of the PHP expression.
  44. * @return mixed the data needed to determine if dependency has been changed.
  45. */
  46. protected function generateDependentData()
  47. {
  48. return $this->evaluateExpression($this->expression);
  49. }
  50. }