Completed
Branch EDTR/master (83b47e)
by
unknown
25:37 queued 16:41
created

Locale::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\domain\entities\routing\data_nodes\core;
4
5
use EEH_DTT_Helper;
6
use EventEspresso\core\services\json\JsonDataNode;
7
use EventEspresso\core\services\json\JsonDataNodeValidator;
8
9
/**
10
 * Class Locale
11
 * Description
12
 *
13
 * @package EventEspresso\core\domain\entities\routing\data_nodes
14
 * @author  Brent Christensen
15
 * @since   $VID:$
16
 */
17
class Locale extends JsonDataNode
18
{
19
20
    const NODE_NAME = 'locale';
21
22
23
    /**
24
     * JsonDataNodeHandler constructor.
25
     *
26
     * @param JsonDataNodeValidator $validator
27
     */
28
    public function __construct(JsonDataNodeValidator $validator)
29
    {
30
        parent::__construct($validator);
31
        $this->setNodeName(Locale::NODE_NAME);
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37
    public function initialize()
38
    {
39
        $this->addData('user', get_user_locale());
40
        $this->addData('site', get_locale());
41
        $this->addData('siteTimezone', [
42
            'city'   => EEH_DTT_Helper::get_timezone_string_for_display(),
43
            'name'   => get_option('timezone_string'),
44
            'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
45
        ]);
46
        $this->setInitialized(true);
47
    }
48
}
49