1 | <?php |
||
49 | class CacheableWidgetBehavior extends Behavior |
||
50 | { |
||
51 | /** |
||
52 | * @var CacheInterface|string|array a cache object or a cache component ID |
||
53 | * or a configuration array for creating a cache object. |
||
54 | * Defaults to the `cache` application component. |
||
55 | */ |
||
56 | public $cache = 'cache'; |
||
57 | /** |
||
58 | * @var int cache duration in seconds. |
||
59 | * Set to `0` to indicate that the cached data will never expire. |
||
60 | * Defaults to 60 seconds or 1 minute. |
||
61 | */ |
||
62 | public $cacheDuration = 60; |
||
63 | /** |
||
64 | * @var Dependency|array|null a cache dependency or a configuration array |
||
65 | * for creating a cache dependency or `null` meaning no cache dependency. |
||
66 | * |
||
67 | * For example, |
||
68 | * |
||
69 | * ```php |
||
70 | * [ |
||
71 | * 'class' => 'yii\caching\DbDependency', |
||
72 | * 'sql' => 'SELECT MAX(updated_at) FROM posts', |
||
73 | * ] |
||
74 | * ``` |
||
75 | * |
||
76 | * would make the widget cache depend on the last modified time of all posts. |
||
77 | * If any post has its modification time changed, the cached content would be invalidated. |
||
78 | */ |
||
79 | public $cacheDependency; |
||
80 | /** |
||
81 | * @var string[]|string an array of strings or a single string which would cause |
||
82 | * the variation of the content being cached (e.g. an application language, a GET parameter). |
||
83 | * |
||
84 | * The following variation setting will cause the content to be cached in different versions |
||
85 | * according to the current application language: |
||
86 | * |
||
87 | * ```php |
||
88 | * [ |
||
89 | * Yii::$app->language, |
||
90 | * ] |
||
91 | * ``` |
||
92 | */ |
||
93 | public $cacheKeyVariations = []; |
||
94 | /** |
||
95 | * @var bool whether to enable caching or not. Allows to turn the widget caching |
||
96 | * on and off according to specific conditions. |
||
97 | * The following configuration will disable caching when a special GET parameter is passed: |
||
98 | * |
||
99 | * ```php |
||
100 | * empty(Yii::$app->request->get('disable-caching')) |
||
101 | * ``` |
||
102 | */ |
||
103 | public $cacheEnabled = true; |
||
104 | |||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | public function attach($owner) |
||
115 | |||
116 | /** |
||
117 | * Begins fragment caching. Prevents owner widget from execution |
||
118 | * if its contents can be retrieved from the cache. |
||
119 | * |
||
120 | * @param WidgetEvent $event `Widget::EVENT_BEFORE_RUN` event. |
||
121 | */ |
||
122 | public function beforeRun($event) |
||
131 | |||
132 | /** |
||
133 | * Outputs widget contents and ends fragment caching. |
||
134 | * |
||
135 | * @param WidgetEvent $event `Widget::EVENT_AFTER_RUN` event. |
||
136 | */ |
||
137 | public function afterRun($event) |
||
144 | |||
145 | /** |
||
146 | * Initializes widget event handlers. |
||
147 | */ |
||
148 | private function initializeEventHandlers() |
||
153 | |||
154 | /** |
||
155 | * Returns the cache instance. |
||
156 | * |
||
157 | * @return CacheInterface cache instance. |
||
158 | * @throws InvalidConfigException if cache instance instantiation fails. |
||
159 | */ |
||
160 | private function getCacheInstance() |
||
165 | |||
166 | /** |
||
167 | * Returns the widget cache key. |
||
168 | * |
||
169 | * @return string[] an array of strings representing the cache key. |
||
170 | */ |
||
171 | private function getCacheKey() |
||
181 | |||
182 | /** |
||
183 | * Returns a fragment cache widget configuration array. |
||
184 | * |
||
185 | * @return array a fragment cache widget configuration array. |
||
186 | */ |
||
187 | private function getFragmentCacheConfiguration() |
||
199 | } |
||
200 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: