-
Notifications
You must be signed in to change notification settings - Fork 116
/
FluentExtension.php
43 lines (36 loc) · 1.01 KB
/
FluentExtension.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
<?php
namespace DNADesign\Elemental\TopPage;
use DNADesign\Elemental\Models\BaseElement;
use DNADesign\Elemental\Models\ElementalArea;
use Page;
use TractorCow\Fluent\State\FluentState;
/**
* Class FluentExtension
*
* Use this extension in case you use the Fluent module (https://github.com/tractorcow-farm/silverstripe-fluent)
* for page localisation
* this will keep track of the locale the nested data object is stored in
*
* @property string $TopPageLocale
* @property BaseElement|ElementalArea|$this $owner
* @package DNADesign\Elemental\TopPage
*/
class FluentExtension extends DataExtension
{
/**
* @var array
*/
private static $db = [
'TopPageLocale' => 'Varchar',
];
protected function assignTopPage(Page $page): void
{
parent::assignTopPage($page);
$this->owner->TopPageLocale = FluentState::singleton()->getLocale();
}
protected function clearTopPage(): void
{
parent::clearTopPage();
$this->owner->TopPageLocale = null;
}
}