Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

47 lines
1.3KB

  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\caching;
  8. use Yii;
  9. use yii\base\InvalidConfigException;
  10. /**
  11. * FileDependency represents a dependency based on a file's last modification time.
  12. *
  13. * If th last modification time of the file specified via [[fileName]] is changed,
  14. * the dependency is considered as changed.
  15. *
  16. * @author Qiang Xue <qiang.xue@gmail.com>
  17. * @since 2.0
  18. */
  19. class FileDependency extends Dependency
  20. {
  21. /**
  22. * @var string the file path or path alias whose last modification time is used to
  23. * check if the dependency has been changed.
  24. */
  25. public $fileName;
  26. /**
  27. * Generates the data needed to determine if dependency has been changed.
  28. * This method returns the file's last modification time.
  29. * @param Cache $cache the cache component that is currently evaluating this dependency
  30. * @return mixed the data needed to determine if dependency has been changed.
  31. * @throws InvalidConfigException if [[fileName]] is not set
  32. */
  33. protected function generateDependencyData($cache)
  34. {
  35. if ($this->fileName === null) {
  36. throw new InvalidConfigException('FileDependency::fileName must be set');
  37. }
  38. return @filemtime(Yii::getAlias($this->fileName));
  39. }
  40. }