-
Notifications
You must be signed in to change notification settings - Fork 691
Expand file tree
/
Copy pathReadOnlyProjectConfigData.php
More file actions
56 lines (48 loc) Β· 1.31 KB
/
ReadOnlyProjectConfigData.php
File metadata and controls
56 lines (48 loc) Β· 1.31 KB
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
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license https://craftcms.github.io/license/
*/
namespace craft\models;
use Craft;
use craft\base\Model;
use craft\helpers\ProjectConfig as ProjectConfigHelper;
use craft\services\ProjectConfig;
/**
* ReadOnlyProjectConfigData model class represents an instance of a project config data structure that cannot be modified
*
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
* @since 4.0.0
*/
class ReadOnlyProjectConfigData extends Model
{
protected array $data;
/** @since 4.4.17 */
protected ProjectConfig $projectConfig;
public function __construct(array $data = [], ?ProjectConfig $projectConfig = null, array $config = [])
{
$this->data = $data;
$this->projectConfig = $projectConfig ?? Craft::$app->getProjectConfig();
parent::__construct($config);
}
/**
* Get a stored data value for a path.
*
* @param string|string[] $path
* @return mixed
*/
public function get(array|string $path): mixed
{
return ProjectConfigHelper::traverseDataArray($this->data, $path);
}
/**
* Export the data to an array.
*
* @return array
*/
public function export(): array
{
return $this->data;
}
}