Skip to content

Commit 62cc95a

Browse files
committed
Added Filesystem::decorateAdapter replica property checks
1 parent 93441c4 commit 62cc95a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Filesystem.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use League\Flysystem\Replicate\ReplicateAdapter;
1212
use Yii;
1313
use yii\base\Component;
14+
use yii\base\InvalidConfigException;
1415

1516
/**
1617
* Filesystem
@@ -81,6 +82,7 @@ abstract protected function prepareAdapter();
8182
/**
8283
* @param \League\Flysystem\AdapterInterface $adapter
8384
* @return \League\Flysystem\AdapterInterface
85+
* @throws InvalidConfigException
8486
*/
8587
protected function decorateAdapter($adapter)
8688
{
@@ -91,6 +93,10 @@ protected function decorateAdapter($adapter)
9193
/* @var Filesystem $filesystem */
9294
$filesystem = Yii::$app->get($this->replica);
9395

96+
if (!$filesystem instanceof Filesystem) {
97+
throw new InvalidConfigException('The "replica" property must be an instance of \creocoder\flysystem\Filesystem subclasses.');
98+
}
99+
94100
return new ReplicateAdapter($adapter, $filesystem->getAdapter());
95101
}
96102

0 commit comments

Comments
 (0)