-
Notifications
You must be signed in to change notification settings - Fork 611
/
Structure.php
56 lines (49 loc) · 1.15 KB
/
Structure.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
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;
/**
* Class Structure model.
*
* @property bool $isSortable whether elements in this structure can be sorted by the current user
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
* @since 3.0.0
*/
class Structure extends Model
{
/**
* @var int|null ID
*/
public ?int $id = null;
/**
* @var int|null Max levels
*/
public ?int $maxLevels = null;
/**
* @var string|null UID
*/
public ?string $uid = null;
/**
* @inheritdoc
*/
protected function defineRules(): array
{
$rules = parent::defineRules();
$rules[] = [['id', 'maxLevels'], 'number', 'integerOnly' => true];
return $rules;
}
/**
* Returns whether elements in this structure can be sorted by the current user.
*
* @return bool
*/
public function getIsSortable(): bool
{
return Craft::$app->getSession()->checkAuthorization('editStructure:' . $this->id);
}
}