diff --git a/src/controllers/DefaultController.php b/src/controllers/DefaultController.php index ea8c937..9a255be 100644 --- a/src/controllers/DefaultController.php +++ b/src/controllers/DefaultController.php @@ -25,6 +25,7 @@ use ReflectionFunction; use yii\base\InvalidConfigException; use yii\base\UserException; +use yii\caching\TagDependency; use yii\web\HttpException; use yii\web\JsonResponseFormatter; use yii\web\Response; @@ -234,7 +235,14 @@ public function actionIndex(string $pattern): Response /** @phpstan-ignore-next-line */ [$dep, $maxDuration] = $elementsService->stopCollectingCacheInfo(); - $dep->tags[] = 'element-api'; + + if (is_null($dep)) { + $dep = new TagDependency([ + 'tags' => ['element-api'], + ]); + } else { + $dep->tags[] = 'element-api'; + } if ($maxDuration) { if ($expire !== null) {