-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.php
45 lines (40 loc) · 1.09 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace darealfive\media;
use darealfive\base\behaviors\property\DirectoryBehavior;
use yii\base\InvalidConfigException;
/**
* Class Module
*
* @package darealfive\media
* @property \yii\base\Module $module
* @property string $imageBasePath the configurable directory in which the images are located.
*/
class Module extends \darealfive\base\Module
{
/**
* Configures virtual property $imageBasePath as a directory to store images
*
* @return array
*/
public function behaviors()
{
return array_merge(parent::behaviors(), [
'imageBasePathDirectory' => [
'class' => DirectoryBehavior::class,
'propertyName' => 'imageBasePath'
]
]);
}
/**
* Checks that this module is configured properly
*
* @throws InvalidConfigException
*/
public function init()
{
parent::init();
if (!is_dir($this->imageBasePath)) {
throw new InvalidConfigException(sprintf('Path "%s" is not a directory', $this->imageBasePath));
}
}
}