3
* @link https://www.yiiframework.com/
4
* @copyright Copyright (c) 2008 Yii Software LLC
5
* @license https://www.yiiframework.com/license/
11
* ChainedDependency represents a dependency which is composed of a list of other dependencies.
13
* When [[dependOnAll]] is true, if any of the dependencies has changed, this dependency is
14
* considered changed; When [[dependOnAll]] is false, if one of the dependencies has NOT changed,
15
* this dependency is considered NOT changed.
17
* For more details and usage information on Cache, see the [guide article on caching](guide:caching-overview).
19
* @author Qiang Xue <qiang.xue@gmail.com>
22
class ChainedDependency extends Dependency
25
* @var Dependency[] list of dependencies that this dependency is composed of.
26
* Each array element must be a dependency object.
28
public $dependencies = [];
30
* @var bool whether this dependency is depending on every dependency in [[dependencies]].
31
* Defaults to true, meaning if any of the dependencies has changed, this dependency is considered changed.
32
* When it is set false, it means if one of the dependencies has NOT changed, this dependency
33
* is considered NOT changed.
35
public $dependOnAll = true;
39
* Evaluates the dependency by generating and saving the data related with dependency.
40
* @param CacheInterface $cache the cache component that is currently evaluating this dependency
42
public function evaluateDependency($cache)
44
foreach ($this->dependencies as $dependency) {
45
$dependency->evaluateDependency($cache);
50
* Generates the data needed to determine if dependency has been changed.
51
* This method does nothing in this class.
52
* @param CacheInterface $cache the cache component that is currently evaluating this dependency
53
* @return mixed the data needed to determine if dependency has been changed.
55
protected function generateDependencyData($cache)
63
public function isChanged($cache)
65
foreach ($this->dependencies as $dependency) {
66
if ($this->dependOnAll && $dependency->isChanged($cache)) {
68
} elseif (!$this->dependOnAll && !$dependency->isChanged($cache)) {
73
return !$this->dependOnAll;